-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathActionLabelEditor.cs
More file actions
66 lines (56 loc) · 2.06 KB
/
ActionLabelEditor.cs
File metadata and controls
66 lines (56 loc) · 2.06 KB
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
#if UNITY_EDITOR
using System.Linq;
using UnityEditor;
////TODO: support multi-object editing
namespace UnityEngine.InputSystem.Samples.RebindUI
{
/// <summary>
/// A custom inspector for <see cref="RebindActionUI"/> which provides a more convenient way for
/// picking the binding which to rebind.
/// </summary>
[CustomEditor(typeof(ActionLabel))]
public class ActionLabelEditor : UnityEditor.Editor
{
protected void OnEnable()
{
m_BindingTextProperty = serializedObject.FindProperty("m_BindingText");
m_UpdateBindingUIEventProperty = serializedObject.FindProperty("m_UpdateBindingUIEvent");
m_BindingUI = new BindingUI(serializedObject);
}
public override void OnInspectorGUI()
{
EditorGUI.BeginChangeCheck();
// Binding section.
m_BindingUI.Draw();
// UI section.
EditorGUILayout.Space();
EditorGUILayout.LabelField(m_UILabel, Styles.boldLabel);
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(m_BindingTextProperty);
}
// Events section.
EditorGUILayout.Space();
EditorGUILayout.LabelField(m_EventsLabel, Styles.boldLabel);
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(m_UpdateBindingUIEventProperty);
}
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
m_BindingUI.Refresh();
}
}
private SerializedProperty m_BindingTextProperty;
private SerializedProperty m_UpdateBindingUIEventProperty;
private GUIContent m_UILabel = new GUIContent("UI");
private GUIContent m_EventsLabel = new GUIContent("Events");
private BindingUI m_BindingUI;
private static class Styles
{
public static GUIStyle boldLabel = new GUIStyle("MiniBoldLabel");
}
}
}
#endif