InputUnlocker.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using BepInEx;
  2. using System;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6. namespace InputUnlocker
  7. {
  8. class InputUnlocker : BaseUnityPlugin
  9. {
  10. public override string ID => "com.bepis.bepinex.inputunlocker";
  11. public override string Name => "Input Length Unlocker";
  12. public override Version Version => new Version("1.0");
  13. void Awake()
  14. {
  15. foreach (InputField gameObject in GameObject.FindObjectsOfType<InputField>())
  16. {
  17. UnlockInput(gameObject);
  18. }
  19. }
  20. void LevelFinishedLoading(Scene scene, LoadSceneMode mode)
  21. {
  22. foreach (GameObject obj in scene.GetRootGameObjects())
  23. foreach (InputField gameObject in obj.GetComponentsInChildren<InputField>(true))
  24. {
  25. UnlockInput(gameObject);
  26. }
  27. }
  28. void UnlockInput(InputField input)
  29. {
  30. input.characterLimit = 999;
  31. }
  32. #region MonoBehaviour
  33. void OnEnable()
  34. {
  35. SceneManager.sceneLoaded += LevelFinishedLoading;
  36. }
  37. void OnDisable()
  38. {
  39. SceneManager.sceneLoaded -= LevelFinishedLoading;
  40. }
  41. #endregion
  42. }
  43. }