@@ -22,14 +22,20 @@ static public DebugActionManager instance
2222 private static string kEnableDebugBtn2 = "Enable Debug Button 2" ;
2323 private static string kDebugPreviousBtn = "Debug Previous" ;
2424 private static string kDebugNextBtn = "Debug Next" ;
25- private string [ ] m_RequiredInputButtons = { kEnableDebugBtn1 , kEnableDebugBtn2 , kDebugPreviousBtn , kDebugNextBtn } ;
25+ private static string kValidateBtn = "Fire1" ;
26+ private static string kDPadVertical = "D-Pad Vertical" ;
27+ private static string kDPadHorizontal = "D-Pad Horizontal" ;
28+ private string [ ] m_RequiredInputButtons = { kEnableDebugBtn1 , kEnableDebugBtn2 , kDebugPreviousBtn , kDebugNextBtn , kValidateBtn , kDPadVertical , kDPadHorizontal } ;
2629
2730
2831 public enum DebugAction
2932 {
3033 EnableDebugMenu ,
3134 PreviousDebugMenu ,
3235 NextDebugMenu ,
36+ Validate ,
37+ MoveVertical ,
38+ MoveHorizontal ,
3339 DebugActionCount
3440 }
3541
@@ -42,6 +48,7 @@ enum DebugActionRepeatMode
4248 class DebugActionDesc
4349 {
4450 public List < string [ ] > buttonTriggerList = new List < string [ ] > ( ) ;
51+ public string axisTrigger = "" ;
4552 public List < KeyCode [ ] > keyTriggerList = new List < KeyCode [ ] > ( ) ;
4653 public DebugActionRepeatMode repeatMode = DebugActionRepeatMode . Never ;
4754 public float repeatDelay = 0.0f ;
@@ -52,24 +59,26 @@ class DebugActionState
5259 enum DebugActionKeyType
5360 {
5461 Button ,
62+ Axis ,
5563 Key
5664 }
5765
5866 DebugActionKeyType m_Type ;
5967 string [ ] m_PressedButtons ;
68+ string m_PressedAxis = "" ;
6069 KeyCode [ ] m_PressedKeys ;
6170 bool [ ] m_TriggerPressedUp = null ;
6271 float m_Timer ;
6372 bool m_RunningAction = false ;
64- bool m_Actiontriggered = false ;
73+ float m_ActionState = 0.0f ;
6574
6675 public bool runningAction { get { return m_RunningAction ; } }
67- public bool actionTriggered { get { return m_Actiontriggered ; } }
76+ public float actionState { get { return m_ActionState ; } }
6877 public float timer { get { return m_Timer ; } }
6978
70- private void Trigger ( int triggerCount )
79+ private void Trigger ( int triggerCount , float state )
7180 {
72- m_Actiontriggered = true ;
81+ m_ActionState = state ;
7382 m_RunningAction = true ;
7483 m_Timer = 0.0f ;
7584
@@ -78,18 +87,27 @@ private void Trigger(int triggerCount)
7887 m_TriggerPressedUp [ i ] = false ;
7988 }
8089
81- public void Trigger ( string [ ] buttons )
90+ public void TriggerWithButton ( string [ ] buttons , float state )
8291 {
8392 m_Type = DebugActionKeyType . Button ;
8493 m_PressedButtons = buttons ;
85- Trigger ( buttons . Length ) ;
94+ m_PressedAxis = "" ;
95+ Trigger ( buttons . Length , state ) ;
8696 }
8797
88- public void Trigger ( KeyCode [ ] keys )
98+ public void TriggerWithAxis ( string axis , float state )
99+ {
100+ m_Type = DebugActionKeyType . Axis ;
101+ m_PressedAxis = axis ;
102+ Trigger ( 1 , state ) ;
103+ }
104+
105+ public void TriggerWithKey ( KeyCode [ ] keys , float state )
89106 {
90107 m_Type = DebugActionKeyType . Key ;
91108 m_PressedKeys = keys ;
92- Trigger ( keys . Length ) ;
109+ m_PressedAxis = "" ;
110+ Trigger ( keys . Length , state ) ;
93111 }
94112
95113 private void Reset ( )
@@ -102,7 +120,7 @@ private void Reset()
102120 public void Update ( DebugActionDesc desc )
103121 {
104122 // Always reset this so that the action can only be caught once until repeat/reset
105- m_Actiontriggered = false ;
123+ m_ActionState = 0.0f ;
106124
107125 if ( m_TriggerPressedUp != null )
108126 {
@@ -112,6 +130,8 @@ public void Update(DebugActionDesc desc)
112130 {
113131 if ( m_Type == DebugActionKeyType . Button )
114132 m_TriggerPressedUp [ i ] |= Input . GetButtonUp ( m_PressedButtons [ i ] ) ;
133+ else if ( m_Type == DebugActionKeyType . Axis )
134+ m_TriggerPressedUp [ i ] |= ( Input . GetAxis ( m_PressedAxis ) == 0.0f ) ;
115135 else
116136 m_TriggerPressedUp [ i ] |= Input . GetKeyUp ( m_PressedKeys [ i ] ) ;
117137 }
@@ -143,7 +163,6 @@ public void Update(DebugActionDesc desc)
143163 enableDebugMenu . buttonTriggerList . Add ( new [ ] { kEnableDebugBtn1 , kEnableDebugBtn2 } ) ;
144164 enableDebugMenu . keyTriggerList . Add ( new [ ] { KeyCode . LeftControl , KeyCode . Backspace } ) ;
145165 enableDebugMenu . repeatMode = DebugActionRepeatMode . Never ;
146-
147166 AddAction ( DebugAction . EnableDebugMenu , enableDebugMenu ) ;
148167
149168 DebugActionDesc nextDebugMenu = new DebugActionDesc ( ) ;
@@ -155,6 +174,15 @@ public void Update(DebugActionDesc desc)
155174 previousDebugMenu . buttonTriggerList . Add ( new [ ] { kDebugPreviousBtn } ) ;
156175 previousDebugMenu . repeatMode = DebugActionRepeatMode . Never ;
157176 AddAction ( DebugAction . PreviousDebugMenu , previousDebugMenu ) ;
177+
178+ DebugActionDesc validate = new DebugActionDesc ( ) ;
179+ validate . buttonTriggerList . Add ( new [ ] { kValidateBtn } ) ;
180+ validate . repeatMode = DebugActionRepeatMode . Delay ;
181+ validate . repeatDelay = 0.25f ;
182+ AddAction ( DebugAction . Validate , validate ) ;
183+
184+ AddAction ( DebugAction . MoveVertical , new DebugActionDesc { axisTrigger = kDPadVertical , repeatMode = DebugActionRepeatMode . Delay , repeatDelay = 0.2f } ) ;
185+ AddAction ( DebugAction . MoveHorizontal , new DebugActionDesc { axisTrigger = kDPadHorizontal , repeatMode = DebugActionRepeatMode . Delay , repeatDelay = 0.2f } ) ;
158186 }
159187
160188 void AddAction ( DebugAction action , DebugActionDesc desc )
@@ -186,11 +214,21 @@ void SampleAction(int actionIndex)
186214
187215 if ( allButtonPressed )
188216 {
189- state . Trigger ( buttons ) ;
217+ state . TriggerWithButton ( buttons , 1.0f ) ;
190218 break ;
191219 }
192220 }
193221
222+ // Check axis triggers
223+ if ( desc . axisTrigger != "" )
224+ {
225+ float axisValue = Input . GetAxis ( desc . axisTrigger ) ;
226+ if ( axisValue != 0.0f )
227+ {
228+ state . TriggerWithAxis ( desc . axisTrigger , axisValue ) ;
229+ }
230+ }
231+
194232 // Check key triggers
195233 for ( int keyListIndex = 0 ; keyListIndex < desc . keyTriggerList . Count ; ++ keyListIndex )
196234 {
@@ -205,7 +243,7 @@ void SampleAction(int actionIndex)
205243
206244 if ( allKeyPressed )
207245 {
208- state . Trigger ( keys ) ;
246+ state . TriggerWithKey ( keys , 1.0f ) ;
209247 break ;
210248 }
211249 }
@@ -235,9 +273,9 @@ public void Update()
235273 }
236274 }
237275
238- public bool GetAction ( DebugAction action )
276+ public float GetAction ( DebugAction action )
239277 {
240- return m_DebugActionStates [ ( int ) action ] . actionTriggered ;
278+ return m_DebugActionStates [ ( int ) action ] . actionState ;
241279 }
242280 }
243281}
0 commit comments