-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathRebindActionParameterUIEditor.cs
More file actions
77 lines (64 loc) · 2.26 KB
/
RebindActionParameterUIEditor.cs
File metadata and controls
77 lines (64 loc) · 2.26 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
67
68
69
70
71
72
73
74
75
76
77
#if UNITY_EDITOR
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
namespace UnityEngine.InputSystem.Samples.RebindUI
{
/// <summary>
/// Allows persisting a parameter override associated with a binding.
/// </summary>
[CustomEditor(typeof(RebindActionParameterUI))]
public class RebindActionParameterUIEditor : UnityEditor.Editor
{
protected void OnEnable()
{
m_Binding = new BindingUI(serializedObject);
m_DefaultValueProperty = serializedObject.FindProperty("m_DefaultValue");
m_PreferenceKeyProperty = serializedObject.FindProperty("m_PreferenceKey");
m_SliderProperty = serializedObject.FindProperty("m_Slider");
m_ParameterOverridesProperty = serializedObject.FindProperty("m_ParameterOverrides");
Refresh();
}
public override void OnInspectorGUI()
{
EditorGUI.BeginChangeCheck();
// Binding section.
m_Binding.Draw();
// UI section
EditorGUILayout.LabelField("UI");
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.ObjectField(m_SliderProperty);
}
// Parameter section.
EditorGUILayout.LabelField("Parameter");
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(m_PreferenceKeyProperty);
EditorGUILayout.PropertyField(m_DefaultValueProperty);
EditorGUILayout.PropertyField(m_ParameterOverridesProperty, true);
}
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
Refresh();
}
}
private void Refresh()
{
m_Binding.Refresh();
}
private struct ParameterValue
{
public string bindingId;
public string name;
}
private SerializedProperty m_PreferenceKeyProperty;
private SerializedProperty m_DefaultValueProperty;
private SerializedProperty m_SliderProperty;
private SerializedProperty m_ParameterOverridesProperty;
private BindingUI m_Binding;
}
}
#endif