SCInputFieldEditor.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEditor;
  5. using UnityEditor.UI;
  6. using UnityEngine;
  7. namespace SC.XR.Unity
  8. {
  9. [CustomEditor(typeof(SCInputField), true)]
  10. [CanEditMultipleObjects]
  11. public class SCInputFieldEditor : InputFieldEditor
  12. {
  13. SerializedProperty m_SCKeyboardEnum;
  14. SerializedProperty m_UseCustomTransform;
  15. SerializedProperty m_CustomLocalPosition;
  16. SerializedProperty m_CustomLocalRotation;
  17. SerializedProperty m_CustomLocalScale;
  18. [MenuItem("GameObject/SC3DUI/SCInputField", priority = 0)]
  19. private static void Init()
  20. {
  21. var obj = Instantiate(Resources.Load<SCInputField>(typeof(SCInputField).Name));
  22. obj.name = (typeof(SCInputField).Name);
  23. if (obj)
  24. {
  25. var parent = Selection.activeGameObject;
  26. obj.transform.SetParent(parent ? parent.transform : null, obj.transform);
  27. Selection.activeGameObject = obj.gameObject;
  28. }
  29. }
  30. protected override void OnEnable()
  31. {
  32. base.OnEnable();
  33. m_SCKeyboardEnum = serializedObject.FindProperty("m_SCKeyboardEnum");
  34. m_UseCustomTransform = serializedObject.FindProperty("m_UseCustomTransform");
  35. m_CustomLocalPosition = serializedObject.FindProperty("m_CustomPosition");
  36. m_CustomLocalRotation = serializedObject.FindProperty("m_CustomRotation");
  37. m_CustomLocalScale = serializedObject.FindProperty("m_CustomLocalScale");
  38. }
  39. public override void OnInspectorGUI()
  40. {
  41. base.OnInspectorGUI();
  42. EditorGUILayout.Space();
  43. EditorGUILayout.PropertyField(m_SCKeyboardEnum);
  44. EditorGUILayout.PropertyField(m_UseCustomTransform);
  45. if (m_UseCustomTransform.boolValue)
  46. {
  47. EditorGUILayout.PropertyField(m_CustomLocalPosition);
  48. EditorGUILayout.PropertyField(m_CustomLocalRotation);
  49. EditorGUILayout.PropertyField(m_CustomLocalScale);
  50. }
  51. serializedObject.ApplyModifiedProperties();
  52. }
  53. }
  54. }