RebuildChecker.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace WebGLSupport.Detail
  5. {
  6. public class RebuildChecker
  7. {
  8. IInputField input;
  9. string beforeString;
  10. int beforeCaretPosition;
  11. int beforeSelectionFocusPosition;
  12. int beforeSelectionAnchorPosition;
  13. //Vector2 anchoredPosition;
  14. public RebuildChecker(IInputField input)
  15. {
  16. this.input = input;
  17. }
  18. public bool NeedRebuild(bool debug = false)
  19. {
  20. var res = false;
  21. // any not same
  22. if (beforeString != input.text)
  23. {
  24. if(debug) Debug.Log(string.Format("beforeString : {0} != {1}", beforeString, input.text));
  25. beforeString = input.text;
  26. res = true;
  27. }
  28. if (beforeCaretPosition != input.caretPosition)
  29. {
  30. if (debug) Debug.Log(string.Format("beforeCaretPosition : {0} != {1}", beforeCaretPosition, input.caretPosition));
  31. beforeCaretPosition = input.caretPosition;
  32. res = true;
  33. }
  34. if (beforeSelectionFocusPosition != input.selectionFocusPosition)
  35. {
  36. if (debug) Debug.Log(string.Format("beforeSelectionFocusPosition : {0} != {1}", beforeSelectionFocusPosition, input.selectionFocusPosition));
  37. beforeSelectionFocusPosition = input.selectionFocusPosition;
  38. res = true;
  39. }
  40. if (beforeSelectionAnchorPosition != input.selectionAnchorPosition)
  41. {
  42. if (debug) Debug.Log(string.Format("beforeSelectionAnchorPosition : {0} != {1}", beforeSelectionAnchorPosition, input.selectionAnchorPosition));
  43. beforeSelectionAnchorPosition = input.selectionAnchorPosition;
  44. res = true;
  45. }
  46. //if (anchoredPosition != input.TextComponentRectTransform().anchoredPosition)
  47. //{
  48. // if (debug) Debug.Log(string.Format("anchoredPosition : {0} != {1}", anchoredPosition, input.TextComponentRectTransform().anchoredPosition));
  49. // anchoredPosition = input.TextComponentRectTransform().anchoredPosition;
  50. // res = true;
  51. //}
  52. return res;
  53. }
  54. }
  55. }