private static void InitializeInputManager() { // HACK: InputSystem has a static constructor that is relied upon for initializing a bunch of other components, so // in edit mode we need to handle lifecycle explicitly InputManager[] managers = Resources.FindObjectsOfTypeAll <InputManager>(); foreach (var m in managers) { U.Object.Destroy(m.gameObject); } managers = Resources.FindObjectsOfTypeAll <InputManager>(); if (managers.Length == 0) { // Attempt creating object hierarchy via an implicit static constructor call by touching the class InputSystem.ExecuteEvents(); managers = Resources.FindObjectsOfTypeAll <InputManager>(); if (managers.Length == 0) { typeof(InputSystem).TypeInitializer.Invoke(null, null); managers = Resources.FindObjectsOfTypeAll <InputManager>(); } } Assert.IsTrue(managers.Length == 1, "Only one InputManager should be active; Count: " + managers.Length); s_InputManager = managers[0]; s_InputManager.gameObject.hideFlags = kDefaultHideFlags; U.Object.SetRunInEditModeRecursively(s_InputManager.gameObject, true); // These components were allocating memory every frame and aren't currently used in EditorVR U.Object.Destroy(s_InputManager.GetComponent <JoystickInputToEvents>()); U.Object.Destroy(s_InputManager.GetComponent <MouseInputToEvents>()); U.Object.Destroy(s_InputManager.GetComponent <KeyboardInputToEvents>()); U.Object.Destroy(s_InputManager.GetComponent <TouchInputToEvents>()); }
public void Update() { InputSystem.ExecuteEvents(); }