11 [CustomEditor(typeof(RangeSlider),
true)]
12 [CanEditMultipleObjects]
15 SerializedProperty m_LowHandleRect;
16 SerializedProperty m_HighHandleRect;
17 SerializedProperty m_FillRect;
19 SerializedProperty m_MinValue;
20 SerializedProperty m_MaxValue;
21 SerializedProperty m_WholeNumbers;
23 SerializedProperty m_LowValue;
24 SerializedProperty m_HighValue;
30 SerializedProperty m_OnValueChanged;
36 m_LowHandleRect = serializedObject.FindProperty(
"m_LowHandleRect");
37 m_HighHandleRect = serializedObject.FindProperty(
"m_HighHandleRect");
38 m_FillRect = serializedObject.FindProperty(
"m_FillRect");
40 m_MinValue = serializedObject.FindProperty(
"m_MinValue");
41 m_MaxValue = serializedObject.FindProperty(
"m_MaxValue");
42 m_WholeNumbers = serializedObject.FindProperty(
"m_WholeNumbers");
44 m_LowValue = serializedObject.FindProperty(
"m_LowValue");
45 low = m_LowValue.floatValue;
46 m_HighValue = serializedObject.FindProperty(
"m_HighValue");
47 high = m_HighValue.floatValue;
49 m_OnValueChanged = serializedObject.FindProperty(
"m_OnValueChanged");
54 base.OnInspectorGUI();
55 EditorGUILayout.Space();
57 serializedObject.Update();
59 low = m_LowValue.floatValue;
60 high = m_HighValue.floatValue;
62 EditorGUILayout.PropertyField(m_LowHandleRect);
63 EditorGUILayout.PropertyField(m_HighHandleRect);
64 EditorGUILayout.PropertyField(m_FillRect);
66 if (m_LowHandleRect.objectReferenceValue !=
null && m_HighHandleRect.objectReferenceValue !=
null)
68 EditorGUI.BeginChangeCheck();
70 EditorGUILayout.PropertyField(m_MinValue);
71 EditorGUILayout.PropertyField(m_MaxValue);
72 EditorGUILayout.PropertyField(m_WholeNumbers);
75 EditorGUILayout.BeginHorizontal();
77 EditorGUILayout.BeginVertical();
78 EditorGUILayout.BeginHorizontal();
79 GUILayout.FlexibleSpace();
80 GUILayout.Label(
"Low");
81 GUILayout.FlexibleSpace();
82 EditorGUILayout.EndHorizontal();
83 low = EditorGUILayout.DelayedFloatField(low, GUILayout.MaxWidth(100));
84 EditorGUILayout.EndVertical();
86 GUILayout.FlexibleSpace();
89 EditorGUILayout.BeginVertical();
90 GUILayout.FlexibleSpace();
91 EditorGUILayout.MinMaxSlider(ref low, ref high, m_MinValue.floatValue, m_MaxValue.floatValue, GUILayout.ExpandWidth(
true));
92 EditorGUILayout.EndVertical();
94 GUILayout.FlexibleSpace();
97 EditorGUILayout.BeginVertical();
98 EditorGUILayout.BeginHorizontal();
99 GUILayout.FlexibleSpace();
100 GUILayout.Label(
"High");
101 GUILayout.FlexibleSpace();
102 EditorGUILayout.EndHorizontal();
103 high = EditorGUILayout.DelayedFloatField(high, GUILayout.MaxWidth(100));
104 EditorGUILayout.EndVertical();
105 EditorGUILayout.EndHorizontal();
107 m_LowValue.floatValue = low;
108 m_HighValue.floatValue = high;
110 EditorGUILayout.Space();
111 EditorGUILayout.PropertyField(m_OnValueChanged);
115 EditorGUILayout.HelpBox(
"Specify a RectTransform for the RangeSlider fill or the RangeSlider handles or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info);
118 serializedObject.ApplyModifiedProperties();
override void OnInspectorGUI()
Credit Erdener Gonenc - @PixelEnvision.