Tanoda
BoxSliderEditor.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3using UnityEngine.UI;
4
6{
7 [CustomEditor(typeof(BoxSlider), true)]
8 [CanEditMultipleObjects]
9 public class BoxSliderEditor : SelectableEditor
10 {
11
12 SerializedProperty m_HandleRect;
13 SerializedProperty m_MinValue;
14 SerializedProperty m_MaxValue;
15 SerializedProperty m_WholeNumbers;
16 SerializedProperty m_Value;
17 SerializedProperty m_ValueY;
18 SerializedProperty m_OnValueChanged;
19
20 protected override void OnEnable()
21 {
22 base.OnEnable();
23 m_HandleRect = serializedObject.FindProperty("m_HandleRect");
24
25 m_MinValue = serializedObject.FindProperty("m_MinValue");
26 m_MaxValue = serializedObject.FindProperty("m_MaxValue");
27 m_WholeNumbers = serializedObject.FindProperty("m_WholeNumbers");
28 m_Value = serializedObject.FindProperty("m_Value");
29 m_ValueY = serializedObject.FindProperty("m_ValueY");
30 m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
31 }
32
33 public override void OnInspectorGUI()
34 {
35 base.OnInspectorGUI();
36 EditorGUILayout.Space();
37
38 serializedObject.Update();
39
40 EditorGUILayout.PropertyField(m_HandleRect);
41
42 if (m_HandleRect.objectReferenceValue != null)
43 {
44 EditorGUI.BeginChangeCheck();
45
46
47 EditorGUILayout.PropertyField(m_MinValue);
48 EditorGUILayout.PropertyField(m_MaxValue);
49 EditorGUILayout.PropertyField(m_WholeNumbers);
50 EditorGUILayout.Slider(m_Value, m_MinValue.floatValue, m_MaxValue.floatValue);
51 EditorGUILayout.Slider(m_ValueY, m_MinValue.floatValue, m_MaxValue.floatValue);
52
53 // Draw the event notification options
54 EditorGUILayout.Space();
55 EditorGUILayout.PropertyField(m_OnValueChanged);
56 }
57 else
58 {
59 EditorGUILayout.HelpBox("Specify a RectTransform for the slider fill or the slider handle or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info);
60 }
61
62 serializedObject.ApplyModifiedProperties();
63 }
64 }
65}