private void OnTransitionComplete() { if (m_OnTransitionComplete != null) { OnTransitionCompleteDelegate temp = m_OnTransitionComplete; m_OnTransitionComplete = null; temp(m_MenuOut, m_MenuIn); } Cleanup(); }
public void StartTransition(GameObject menuOut, GameObject menuIn, TransitionData data, OnTransitionCompleteDelegate completionCallback) { if (IsTransitioning) { Services.Logger.LogError("Attempting to start transition - MI: {0}, MO: {1}"); } m_MenuOut = menuOut; m_MenuIn = menuIn; if (!menuIn.activeSelf) { menuIn.SetActive(true); } if (!menuOut.activeSelf) { menuOut.SetActive(true); } m_CurrentTransitionData = data; m_OnTransitionComplete = completionCallback; float xPos = 0; if ((m_CurrentTransitionData.Direction & (eDirection.LEFT | eDirection.RIGHT)) != 0) { float multiplier = (m_CurrentTransitionData.Direction & eDirection.RIGHT) == eDirection.RIGHT ? 1 : -1; xPos = Screen.width * multiplier; } float yPos = 0; if ((m_CurrentTransitionData.Direction & (eDirection.TOP | eDirection.BOTTOM)) != 0) { float multiplier = (m_CurrentTransitionData.Direction & eDirection.TOP) == eDirection.TOP ? 1 : -1; yPos = Screen.height * multiplier; } menuIn.transform.localPosition = new Vector3(-xPos, -yPos, 0); m_TransitionOutTweener = menuOut.transform. DOBlendableLocalMoveBy(new Vector3(xPos, yPos, 0), m_CurrentTransitionData.Duration). SetEase(m_CurrentTransitionData.EaseType); m_TransitionInTweener = menuIn.transform. DOBlendableLocalMoveBy(new Vector3(xPos, yPos, 0), m_CurrentTransitionData.Duration). SetEase(m_CurrentTransitionData.EaseType). OnComplete(OnTransitionComplete); }