TMP_DropdownEditor.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEngine;
  2. using UnityEditor;
  3. using UnityEditor.UI;
  4. using UnityEngine.UI;
  5. namespace TMPro.EditorUtilities
  6. {
  7. [CustomEditor(typeof(TMP_Dropdown), true)]
  8. [CanEditMultipleObjects]
  9. public class DropdownEditor : SelectableEditor
  10. {
  11. SerializedProperty m_Template;
  12. SerializedProperty m_CaptionText;
  13. SerializedProperty m_CaptionImage;
  14. SerializedProperty m_ItemText;
  15. SerializedProperty m_ItemImage;
  16. SerializedProperty m_OnSelectionChanged;
  17. SerializedProperty m_Value;
  18. SerializedProperty m_Options;
  19. protected override void OnEnable()
  20. {
  21. base.OnEnable();
  22. m_Template = serializedObject.FindProperty("m_Template");
  23. m_CaptionText = serializedObject.FindProperty("m_CaptionText");
  24. m_CaptionImage = serializedObject.FindProperty("m_CaptionImage");
  25. m_ItemText = serializedObject.FindProperty("m_ItemText");
  26. m_ItemImage = serializedObject.FindProperty("m_ItemImage");
  27. m_OnSelectionChanged = serializedObject.FindProperty("m_OnValueChanged");
  28. m_Value = serializedObject.FindProperty("m_Value");
  29. m_Options = serializedObject.FindProperty("m_Options");
  30. }
  31. public override void OnInspectorGUI()
  32. {
  33. base.OnInspectorGUI();
  34. EditorGUILayout.Space();
  35. serializedObject.Update();
  36. EditorGUILayout.PropertyField(m_Template);
  37. EditorGUILayout.PropertyField(m_CaptionText);
  38. EditorGUILayout.PropertyField(m_CaptionImage);
  39. EditorGUILayout.PropertyField(m_ItemText);
  40. EditorGUILayout.PropertyField(m_ItemImage);
  41. EditorGUILayout.PropertyField(m_Value);
  42. EditorGUILayout.PropertyField(m_Options);
  43. EditorGUILayout.PropertyField(m_OnSelectionChanged);
  44. serializedObject.ApplyModifiedProperties();
  45. }
  46. }
  47. }