Skip to content

Commit 87a5590

Browse files
committed
Removed obsolete editor code and simplified game manager
1 parent 1e95882 commit 87a5590

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

Assets/Samples/RebindingUI/RebindActionUIEditor.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ protected void OnEnable()
2121
m_BindingTextProperty = serializedObject.FindProperty("m_BindingText");
2222
m_RebindOverlayProperty = serializedObject.FindProperty("m_RebindOverlay");
2323
m_RebindTextProperty = serializedObject.FindProperty("m_RebindText");
24-
m_DefaultInputActionsProperty = serializedObject.FindProperty("m_DefaultInputActions");
2524
m_UpdateBindingUIEventProperty = serializedObject.FindProperty("m_UpdateBindingUIEvent");
2625
m_RebindStartEventProperty = serializedObject.FindProperty("m_RebindStartEvent");
2726
m_RebindStopEventProperty = serializedObject.FindProperty("m_RebindStopEvent");
@@ -63,7 +62,6 @@ public override void OnInspectorGUI()
6362
EditorGUILayout.PropertyField(m_BindingTextProperty);
6463
EditorGUILayout.PropertyField(m_RebindOverlayProperty);
6564
EditorGUILayout.PropertyField(m_RebindTextProperty);
66-
EditorGUILayout.PropertyField(m_DefaultInputActionsProperty);
6765
}
6866

6967
// Events section.
@@ -155,7 +153,6 @@ protected void RefreshBindingOptions()
155153
private SerializedProperty m_BindingIdProperty;
156154
private SerializedProperty m_ActionLabelProperty;
157155
private SerializedProperty m_BindingTextProperty;
158-
private SerializedProperty m_DefaultInputActionsProperty;
159156
private SerializedProperty m_RebindOverlayProperty;
160157
private SerializedProperty m_RebindTextProperty;
161158
private SerializedProperty m_RebindStartEventProperty;

Assets/Samples/RebindingUI/RebindUIGameManager.cs

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,32 @@ private enum GameState
4343
private GameState m_CurrentState = GameState.Initializing;
4444
private GameState m_NextState = GameState.Playing;
4545

46-
private void SetState(GameState newState)
46+
private void OnToggleMenu(InputAction.CallbackContext obj)
47+
{
48+
ToggleMenu();
49+
}
50+
51+
private void OnEnable()
52+
{
53+
toggleMenuAction.action.performed += OnToggleMenu;
54+
}
55+
56+
private void OnDisable()
57+
{
58+
toggleMenuAction.action.performed -= OnToggleMenu;
59+
}
60+
61+
private void Update()
4762
{
4863
// Abort if there is no change to state
49-
if (newState == m_CurrentState)
64+
if (m_CurrentState == m_NextState)
5065
return;
5166

5267
// Update current state
53-
m_CurrentState = newState;
68+
m_CurrentState = m_NextState;
5469

55-
switch (newState)
70+
// Handle state transition
71+
switch (m_NextState)
5672
{
5773
// Entering game mode: enable in-game actions, show menu
5874
case GameState.Playing:
@@ -70,29 +86,6 @@ private void SetState(GameState newState)
7086
EventSystem.current.SetSelectedGameObject(EventSystem.current.firstSelectedGameObject);
7187
break;
7288
}
73-
74-
Debug.Log(m_CurrentState);
75-
}
76-
77-
private void OnToggleMenu(InputAction.CallbackContext obj)
78-
{
79-
ToggleMenu();
80-
}
81-
82-
private void OnEnable()
83-
{
84-
toggleMenuAction.action.performed += OnToggleMenu;
85-
}
86-
87-
private void OnDisable()
88-
{
89-
toggleMenuAction.action.performed -= OnToggleMenu;
90-
}
91-
92-
private void Update()
93-
{
94-
if (m_CurrentState != m_NextState)
95-
SetState(m_NextState);
9689
}
9790
}
9891
}

0 commit comments

Comments
 (0)