// Use this for initialization void Start() { if (s_Instance == null) { s_Instance = this; } else { Debug.LogWarning("Attempting to create more than one \'Input Manager\'"); Debug.LogWarning("Floating GameObject " + gameObject.name); if (Application.isPlaying) { Destroy(this); } else { DestroyImmediate(this); } return; } DontDestroyOnLoad(gameObject); //if (Application.isPlaying == false) //{ // setDefault(); // internal_SaveEditor(); //} if (Application.isPlaying) { for (int i = 0; i < m_Axis.Count; i++) { if (m_Axis[i] != null) { m_Axis[i].start(); } } } }
void OnDestroy() { if (s_Instance == this) { s_Instance = null; } }
private void OnInspectorUpdate() { if(m_Repaint == true) { Repaint(); m_Repaint = false; } if (m_State == State.INIT) { if (m_StartPressed && m_Root != null) { m_StartPressed = false; m_InputManager = m_Root.GetComponent<InputManager>(); if (m_InputManager == null) { //If there is a input manager. Ask the user if they want to use it instead. m_InputManager = InputManager.instance; if (m_InputManager != null) { m_State = State.TRANSFER_GAME_OBJECT_SETUP; }//Otherwise go straight into setup else { m_InputManager = m_Root.AddComponent<InputManager>(); m_State = State.SETUP; } } else { m_State = State.SETUP; } } } else if (m_State == State.TRANSFER_GAME_OBJECT_SETUP) { if (m_Root == null) { m_State = State.INIT; return; } if (m_YesPressed == true && m_Root != null) { m_YesPressed = false; m_NoPressed = false; if (m_InputManager != null) { Component[] components = m_Root.GetComponents<Component>(); if (components.Length <= 1) { DestroyImmediate(m_Root); } m_Root = m_InputManager.gameObject; m_State = State.SETUP; } else { m_State = State.INIT; } } else if (m_NoPressed == true && m_Root != null) { m_YesPressed = false; m_NoPressed = false; if (m_InputManager != null) { DestroyImmediate(m_InputManager); m_Root.AddComponent<InputManager>(); m_State = State.SETUP; } else { m_Root.AddComponent<InputManager>(); m_State = State.SETUP; } } } else if (m_State == State.SETUP) { if (m_InputManager == null || m_Root == null) { m_State = State.INIT; return; } } }