1+ using UnityEditor ;
2+ using UnityEditor . UI ;
3+
4+ /// <summary>
5+ /// Custom editor so that YahalomCheckbox's extra serialized fields
6+ /// are visible alongside the standard Toggle inspector.
7+ /// </summary>
8+ [ CustomEditor ( typeof ( YahalomCheckbox ) ) ]
9+ [ CanEditMultipleObjects ]
10+ public class YahalomToggleEditor : ToggleEditor
11+ {
12+ private SerializedProperty _toggleImage ;
13+ private SerializedProperty _checkedSprite ;
14+ private SerializedProperty _uncheckedSprite ;
15+ private SerializedProperty _disabledSprite ;
16+ private SerializedProperty _partialSprite ;
17+ private SerializedProperty _isPartial ;
18+
19+ protected override void OnEnable ( )
20+ {
21+ base . OnEnable ( ) ;
22+
23+ _toggleImage = serializedObject . FindProperty ( "_toggleImage" ) ;
24+ _checkedSprite = serializedObject . FindProperty ( "_checkedSprite" ) ;
25+ _uncheckedSprite = serializedObject . FindProperty ( "_uncheckedSprite" ) ;
26+ _disabledSprite = serializedObject . FindProperty ( "_disabledSprite" ) ;
27+ _partialSprite = serializedObject . FindProperty ( "_partialSprite" ) ;
28+ _isPartial = serializedObject . FindProperty ( "_isPartial" ) ;
29+ }
30+
31+ public override void OnInspectorGUI ( )
32+ {
33+ // We intentionally do NOT call base.OnInspectorGUI() so we can
34+ // skip the Selectable "Transition" block which is not used.
35+
36+ serializedObject . Update ( ) ;
37+
38+ // Draw the base Selectable fields except Transition.
39+ DrawSelectablePropertiesExcludingTransition ( ) ;
40+
41+ // Draw the standard Toggle-specific fields.
42+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "m_IsOn" ) ) ;
43+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "toggleTransition" ) ) ;
44+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "graphic" ) ) ;
45+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "m_Group" ) ) ;
46+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "onValueChanged" ) ) ;
47+
48+ EditorGUILayout . Space ( ) ;
49+ EditorGUILayout . LabelField ( "Yahalom Toggle Sprites" , EditorStyles . boldLabel ) ;
50+ EditorGUILayout . PropertyField ( _toggleImage ) ;
51+ EditorGUILayout . PropertyField ( _checkedSprite ) ;
52+ EditorGUILayout . PropertyField ( _uncheckedSprite ) ;
53+ EditorGUILayout . PropertyField ( _disabledSprite ) ;
54+ EditorGUILayout . PropertyField ( _partialSprite ) ;
55+
56+ EditorGUILayout . Space ( ) ;
57+ EditorGUILayout . LabelField ( "Yahalom Toggle State" , EditorStyles . boldLabel ) ;
58+ EditorGUILayout . PropertyField ( _isPartial ) ;
59+
60+ serializedObject . ApplyModifiedProperties ( ) ;
61+ }
62+
63+ /// <summary>
64+ /// Draws the common Selectable fields but hides the Transition block.
65+ /// This mirrors Unity's SelectableEditor minus the transition UI.
66+ /// </summary>
67+ private void DrawSelectablePropertiesExcludingTransition ( )
68+ {
69+ // Navigation
70+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "m_Navigation" ) ) ;
71+
72+ // Interactable
73+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "m_Interactable" ) ) ;
74+
75+ // Target graphic (but no transition config)
76+ EditorGUILayout . PropertyField ( serializedObject . FindProperty ( "m_TargetGraphic" ) ) ;
77+
78+ // Colors / Sprite state / AnimationTriggers are normally grouped under Transition;
79+ // since Transition is unused for this toggle, we omit those blocks entirely.
80+ }
81+ }
0 commit comments