SCInputFieldTool.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEditor;
  5. using UnityEditor.SceneManagement;
  6. using UnityEngine;
  7. using UnityEngine.Events;
  8. using UnityEngine.UI;
  9. using SC.XR.Unity.Module_Keyboard;
  10. using SC.XR.Unity;
  11. public class SCInputFieldTool : Editor
  12. {
  13. [MenuItem("Tools/SCInputField => SCInputField")]
  14. private static void ChangeSCInputFieldColor()
  15. {
  16. if (Selection.objects.Length > 0)
  17. {
  18. for (int i = 0; i < Selection.objects.Length; i++)
  19. {
  20. if ((Selection.objects[i] as GameObject).GetComponent<SC.XR.Unity.SCInputField>())
  21. {
  22. GameObject obj = Selection.objects[i] as GameObject;
  23. SC.XR.Unity.SCInputField o_SCInputField = obj.GetComponent<SC.XR.Unity.SCInputField>();
  24. GameObject o = new GameObject();
  25. UGUI_SCInputField n_SCInputField = o.AddComponent<UGUI_SCInputField>();
  26. n_SCInputField.text = o_SCInputField.text;
  27. n_SCInputField.placeholder = o_SCInputField.placeholder;
  28. n_SCInputField.targetGraphic = o_SCInputField.targetGraphic;
  29. n_SCInputField.colors = o_SCInputField.colors;
  30. n_SCInputField.navigation = o_SCInputField.navigation;
  31. n_SCInputField.textComponent = o_SCInputField.textComponent;
  32. n_SCInputField.characterLimit = o_SCInputField.characterLimit;
  33. n_SCInputField.contentType = (UGUI_SCInputField.ContentType)o_SCInputField.contentType;
  34. n_SCInputField.lineType = (UGUI_SCInputField.LineType)o_SCInputField.lineType;
  35. n_SCInputField.caretBlinkRate = o_SCInputField.caretBlinkRate;
  36. n_SCInputField.caretWidth = o_SCInputField.caretWidth;
  37. n_SCInputField.customCaretColor = o_SCInputField.customCaretColor;
  38. n_SCInputField.selectionColor = o_SCInputField.selectionColor;
  39. n_SCInputField.shouldHideMobileInput = o_SCInputField.shouldHideMobileInput;
  40. n_SCInputField.readOnly = o_SCInputField.readOnly;
  41. Undo.DestroyObjectImmediate(o_SCInputField);
  42. UGUI_SCInputField new_SCInputField = Undo.AddComponent<UGUI_SCInputField>(obj);
  43. new_SCInputField.text = n_SCInputField.text;
  44. new_SCInputField.placeholder = n_SCInputField.placeholder;
  45. new_SCInputField.targetGraphic = n_SCInputField.targetGraphic;
  46. new_SCInputField.colors = n_SCInputField.colors;
  47. new_SCInputField.navigation = n_SCInputField.navigation;
  48. new_SCInputField.textComponent = n_SCInputField.textComponent;
  49. new_SCInputField.characterLimit = n_SCInputField.characterLimit;
  50. new_SCInputField.contentType = (UGUI_SCInputField.ContentType)n_SCInputField.contentType;
  51. new_SCInputField.lineType = (UGUI_SCInputField.LineType)n_SCInputField.lineType;
  52. new_SCInputField.caretBlinkRate = n_SCInputField.caretBlinkRate;
  53. new_SCInputField.caretWidth = n_SCInputField.caretWidth;
  54. new_SCInputField.customCaretColor = n_SCInputField.customCaretColor;
  55. new_SCInputField.selectionColor = n_SCInputField.selectionColor;
  56. new_SCInputField.shouldHideMobileInput = n_SCInputField.shouldHideMobileInput;
  57. new_SCInputField.readOnly = n_SCInputField.readOnly;
  58. UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
  59. UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
  60. UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
  61. UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
  62. UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
  63. UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
  64. UnityEditorInternal.ComponentUtility.MoveComponentDown(new_SCInputField);
  65. UnityEditorInternal.ComponentUtility.MoveComponentDown(new_SCInputField);
  66. DestroyImmediate(o);
  67. }
  68. }
  69. }
  70. }
  71. }