1 #pragma warning disable 0649 4 using System.Collections.Generic;
6 namespace HKI.Core.GameSystems.Input
11 [CreateAssetMenu(fileName =
"Input System", menuName =
"HKI/Game Systems/Input System", order = 0)]
29 int inputHandlersLength = 0;
38 public override IEnumerator
Init()
40 bool validationSuccessful =
true;
43 Validate(
"key toggle", KeyToggleInputHandlers, ref validationSuccessful);
44 Validate(
"key down", KeyDownInputHandlers, ref validationSuccessful);
45 Validate(
"key up", KeyUpInputHandlers, ref validationSuccessful);
46 Validate(
"key ", KeyInputHandlers, ref validationSuccessful);
49 Validate(
"mouse position", MousePositionInputHandler, ref validationSuccessful);
50 Validate(
"mouse button down", MouseButtonDownInputHandlers, ref validationSuccessful);
51 Validate(
"mouse button up", MouseButtonUpInputHandlers, ref validationSuccessful);
52 Validate(
"mouse button", MouseButtonInputHandlers, ref validationSuccessful);
55 Validate(
"axis", AxisInputHandlers, ref validationSuccessful);
56 Validate(
"axis raw", AxisRawInputHandlers, ref validationSuccessful);
58 List<InputHandler> inputHandlersList =
new List<InputHandler>();
61 if (KeyToggleInputHandlers != null && KeyToggleInputHandlers.Length > 0)
62 inputHandlersList.AddRange(KeyToggleInputHandlers);
64 if (KeyDownInputHandlers != null && KeyDownInputHandlers.Length > 0)
65 inputHandlersList.AddRange(KeyDownInputHandlers);
67 if(KeyUpInputHandlers != null && KeyUpInputHandlers.Length > 0)
68 inputHandlersList.AddRange(KeyUpInputHandlers);
70 if(KeyInputHandlers != null && KeyInputHandlers.Length > 0)
71 inputHandlersList.AddRange(KeyInputHandlers);
74 inputHandlersList.Add(MousePositionInputHandler);
76 if (MouseButtonDownInputHandlers != null && MouseButtonDownInputHandlers.Length > 0)
77 inputHandlersList.AddRange(MouseButtonDownInputHandlers);
79 if (MouseButtonUpInputHandlers != null && MouseButtonUpInputHandlers.Length > 0)
80 inputHandlersList.AddRange(MouseButtonUpInputHandlers);
82 if (MouseButtonInputHandlers != null && MouseButtonInputHandlers.Length > 0)
83 inputHandlersList.AddRange(MouseButtonInputHandlers);
86 if (AxisInputHandlers != null && AxisInputHandlers.Length > 0)
87 inputHandlersList.AddRange(AxisInputHandlers);
89 if (AxisRawInputHandlers != null && AxisRawInputHandlers.Length > 0)
90 inputHandlersList.AddRange(AxisRawInputHandlers);
92 inputHandlers = inputHandlersList.ToArray();
93 inputHandlersLength = inputHandlers.Length;
95 initSuccessful = validationSuccessful;
106 if(inputHandlers != null)
108 for (
int i = 0; i < inputHandlersLength; i++)
109 inputHandlers[i].Update();
122 if(inputhandler != null)
126 Debug.LogError(
"(InputSystem) validation failed on " + inputHandlerTypeName +
" input handler");
127 validationSuccessful =
false;
140 if(inputhandlers != null)
142 for (
int i = 0; i < inputhandlers.Length; i++)
144 if (!inputhandlers[i].Validate())
146 Debug.LogError(
"(InputSystem) validation failed on " + inputHandlerTypeName +
" input handler with the index: " + i.ToString());
147 validationSuccessful =
false;
This ScriptableObject is the abstract base class for all GameSystems. It provides "interface" functio...