123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEditor;
- using UnityEditor.SceneManagement;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- using SC.XR.Unity.Module_Keyboard;
- using SC.XR.Unity;
- public class SCInputFieldTool : Editor
- {
- [MenuItem("Tools/SCInputField => SCInputField")]
- private static void ChangeSCInputFieldColor()
- {
- if (Selection.objects.Length > 0)
- {
- for (int i = 0; i < Selection.objects.Length; i++)
- {
- if ((Selection.objects[i] as GameObject).GetComponent<SC.XR.Unity.SCInputField>())
- {
- GameObject obj = Selection.objects[i] as GameObject;
- SC.XR.Unity.SCInputField o_SCInputField = obj.GetComponent<SC.XR.Unity.SCInputField>();
- GameObject o = new GameObject();
- UGUI_SCInputField n_SCInputField = o.AddComponent<UGUI_SCInputField>();
- n_SCInputField.text = o_SCInputField.text;
- n_SCInputField.placeholder = o_SCInputField.placeholder;
- n_SCInputField.targetGraphic = o_SCInputField.targetGraphic;
- n_SCInputField.colors = o_SCInputField.colors;
- n_SCInputField.navigation = o_SCInputField.navigation;
- n_SCInputField.textComponent = o_SCInputField.textComponent;
- n_SCInputField.characterLimit = o_SCInputField.characterLimit;
- n_SCInputField.contentType = (UGUI_SCInputField.ContentType)o_SCInputField.contentType;
- n_SCInputField.lineType = (UGUI_SCInputField.LineType)o_SCInputField.lineType;
- n_SCInputField.caretBlinkRate = o_SCInputField.caretBlinkRate;
- n_SCInputField.caretWidth = o_SCInputField.caretWidth;
- n_SCInputField.customCaretColor = o_SCInputField.customCaretColor;
- n_SCInputField.selectionColor = o_SCInputField.selectionColor;
- n_SCInputField.shouldHideMobileInput = o_SCInputField.shouldHideMobileInput;
- n_SCInputField.readOnly = o_SCInputField.readOnly;
-
- Undo.DestroyObjectImmediate(o_SCInputField);
- UGUI_SCInputField new_SCInputField = Undo.AddComponent<UGUI_SCInputField>(obj);
- new_SCInputField.text = n_SCInputField.text;
- new_SCInputField.placeholder = n_SCInputField.placeholder;
- new_SCInputField.targetGraphic = n_SCInputField.targetGraphic;
- new_SCInputField.colors = n_SCInputField.colors;
- new_SCInputField.navigation = n_SCInputField.navigation;
- new_SCInputField.textComponent = n_SCInputField.textComponent;
- new_SCInputField.characterLimit = n_SCInputField.characterLimit;
- new_SCInputField.contentType = (UGUI_SCInputField.ContentType)n_SCInputField.contentType;
- new_SCInputField.lineType = (UGUI_SCInputField.LineType)n_SCInputField.lineType;
- new_SCInputField.caretBlinkRate = n_SCInputField.caretBlinkRate;
- new_SCInputField.caretWidth = n_SCInputField.caretWidth;
- new_SCInputField.customCaretColor = n_SCInputField.customCaretColor;
- new_SCInputField.selectionColor = n_SCInputField.selectionColor;
- new_SCInputField.shouldHideMobileInput = n_SCInputField.shouldHideMobileInput;
- new_SCInputField.readOnly = n_SCInputField.readOnly;
- UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
- UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
- UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
- UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
- UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
- UnityEditorInternal.ComponentUtility.MoveComponentUp(new_SCInputField);
- UnityEditorInternal.ComponentUtility.MoveComponentDown(new_SCInputField);
- UnityEditorInternal.ComponentUtility.MoveComponentDown(new_SCInputField);
- DestroyImmediate(o);
- }
- }
- }
- }
- }
|