public void SetState(T state)
    {
        int stateIndex = (int)(object)state;

        if (stateIndex == m_CurrentStateIndex)
        {
            return;
        }

        // Leave current state
        if (m_CurrentStateCallbacks != null && m_CurrentStateCallbacks.exitStateCallback != null)
        {
            m_CurrentStateCallbacks.exitStateCallback();
        }

        // Set state
        m_CurrentStateIndex     = stateIndex;
        m_CurrentStateCallbacks = m_StateCallbacks[m_CurrentStateIndex];

        // Enter new state
        if (m_CurrentStateCallbacks != null && m_CurrentStateCallbacks.enterStateCallback != null)
        {
            m_CurrentStateCallbacks.enterStateCallback();
        }
    }