miepzerino
2025-03-30 d2ab30e7a69bfe7efda63ae75812207377917bd3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#if UNITY_PHYSICS
 
using UnityEditor;
using UnityEngine;
 
namespace Flexalon.Editor
{
    [CustomEditor(typeof(FlexalonInteractable)), CanEditMultipleObjects]
    public class FlexalonInteractableEditor : UnityEditor.Editor
    {
        private SerializedProperty _clickable;
        private SerializedProperty _maxClickTime;
        private SerializedProperty _draggable;
        private SerializedProperty _interpolationSpeed;
        private SerializedProperty _insertRadius;
        private SerializedProperty _restriction;
        private SerializedProperty _planeNormal;
        private SerializedProperty _localSpaceRestriction;
        private SerializedProperty _lineDirection;
        private SerializedProperty _holdOffset;
        private SerializedProperty _localSpaceOffset;
        private SerializedProperty _rotateOnDrag;
        private SerializedProperty _holdRotation;
        private SerializedProperty _localSpaceRotation;
        private SerializedProperty _hideCursor;
        private SerializedProperty _handle;
        private SerializedProperty _bounds;
        private SerializedProperty _layerMask;
        private SerializedProperty _clicked;
        private SerializedProperty _hoverStart;
        private SerializedProperty _hoverEnd;
        private SerializedProperty _selectStart;
        private SerializedProperty _selectEnd;
        private SerializedProperty _dragStart;
        private SerializedProperty _dragEnd;
 
        private static bool _showDragOptions = true;
        private static bool _showEvents = false;
 
        void OnEnable()
        {
            _clickable = serializedObject.FindProperty("_clickable");
            _maxClickTime = serializedObject.FindProperty("_maxClickTime");
            _draggable = serializedObject.FindProperty("_draggable");
            _interpolationSpeed = serializedObject.FindProperty("_interpolationSpeed");
            _insertRadius = serializedObject.FindProperty("_insertRadius");
            _restriction = serializedObject.FindProperty("_restriction");
            _planeNormal = serializedObject.FindProperty("_planeNormal");
            _localSpaceRestriction = serializedObject.FindProperty("_localSpaceRestriction");
            _lineDirection = serializedObject.FindProperty("_lineDirection");
            _holdOffset = serializedObject.FindProperty("_holdOffset");
            _localSpaceOffset = serializedObject.FindProperty("_localSpaceOffset");
            _rotateOnDrag = serializedObject.FindProperty("_rotateOnDrag");
            _holdRotation = serializedObject.FindProperty("_holdRotation");
            _localSpaceRotation = serializedObject.FindProperty("_localSpaceRotation");
            _hideCursor = serializedObject.FindProperty("_hideCursor");
            _handle = serializedObject.FindProperty("_handle");
            _bounds = serializedObject.FindProperty("_bounds");
            _layerMask = serializedObject.FindProperty("_layerMask");
            _clicked = serializedObject.FindProperty("_clicked");
            _hoverStart = serializedObject.FindProperty("_hoverStart");
            _hoverEnd = serializedObject.FindProperty("_hoverEnd");
            _selectStart = serializedObject.FindProperty("_selectStart");
            _selectEnd = serializedObject.FindProperty("_selectEnd");
            _dragStart = serializedObject.FindProperty("_dragStart");
            _dragEnd = serializedObject.FindProperty("_dragEnd");
        }
 
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.PropertyField(_clickable);
 
            if (_clickable.boolValue)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(serializedObject.FindProperty("_maxClickTime"), new GUIContent("Max Click Time"));
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
 
            EditorGUILayout.PropertyField(_draggable);
 
            if (_draggable.boolValue)
            {
                EditorGUILayout.Space();
                _showDragOptions = EditorGUILayout.Foldout(_showDragOptions, "Drag Options");
                if (_showDragOptions)
                {
                    EditorGUI.indentLevel++;
 
                    bool showAllOptions = true;
                    foreach (var target in targets)
                    {
                        var interactable = target as FlexalonInteractable;
                        showAllOptions = showAllOptions && interactable._showAllDragProperties;
                    }
 
                    if (showAllOptions)
                    {
                        EditorGUILayout.PropertyField(_interpolationSpeed);
                    }
 
                    EditorGUILayout.PropertyField(_insertRadius);
 
                    if (showAllOptions)
                    {
                        var restriction = _restriction;
                        EditorGUILayout.PropertyField(restriction);
                        if (restriction.enumValueIndex == (int)FlexalonInteractable.RestrictionType.Plane)
                        {
                            EditorGUI.indentLevel++;
                            EditorGUILayout.PropertyField(_planeNormal, new GUIContent("Normal"));
                            EditorGUILayout.PropertyField(_localSpaceRestriction, new GUIContent("Local Space"));
                            EditorGUI.indentLevel--;
                        }
                        else if (restriction.enumValueIndex == (int)FlexalonInteractable.RestrictionType.Line)
                        {
                            EditorGUI.indentLevel++;
                            EditorGUILayout.PropertyField(_lineDirection, new GUIContent("Direction"));
                            EditorGUILayout.PropertyField(_localSpaceRestriction, new GUIContent("Local Space"));
                            EditorGUI.indentLevel--;
                        }
 
                        EditorGUILayout.PropertyField(_holdOffset);
                        EditorGUILayout.PropertyField(_localSpaceOffset, new GUIContent("Local Space"));
 
                        var rotateOnGrab = _rotateOnDrag;
                        EditorGUILayout.PropertyField(rotateOnGrab);
                        if (rotateOnGrab.boolValue)
                        {
                            EditorGUI.indentLevel++;
                            EditorGUILayout.PropertyField(_holdRotation, new GUIContent("Rotation"));
                            EditorGUILayout.PropertyField(_localSpaceRotation, new GUIContent("Local Space"));
                            EditorGUI.indentLevel--;
                        }
 
                        EditorGUILayout.PropertyField(_handle);
                        EditorGUILayout.PropertyField(_bounds);
                    }
                    else
                    {
                        EditorGUILayout.Space();
                        EditorGUILayout.HelpBox("Some drag options are disabled for the selected input provider.", MessageType.Info);
                        EditorGUILayout.Space();
                    }
 
                    EditorGUILayout.PropertyField(_hideCursor);
                    EditorGUILayout.PropertyField(_layerMask);
                    EditorGUI.indentLevel--;
                }
            }
 
            EditorGUILayout.Space();
 
            _showEvents = EditorGUILayout.Foldout(_showEvents, "Events");
            if (_showEvents)
            {
                if (_clickable.boolValue)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("_clicked"));
                }
 
                EditorGUILayout.PropertyField(serializedObject.FindProperty("_hoverStart"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("_hoverEnd"));
 
                EditorGUILayout.PropertyField(serializedObject.FindProperty("_selectStart"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("_selectEnd"));
 
                if (_draggable.boolValue)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("_dragStart"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("_dragEnd"));
                }
            }
 
            serializedObject.ApplyModifiedProperties();
        }
    }
}
 
#endif