// Queues a transition to play following the previous (currently-running) transition protected void QueueTransition(int newState, int prevState, bool suppressTransition) { if (deleted) { return; } nextTransition = transitions[newState].list[DetermineNextTransition(newState, prevState)]; nextState = (CONTROL_STATE)newState; if (suppressTransition) { prevTransition.End(); prevTransition = nextTransition; prevTransition.Start(); prevTransition.End(); // Immediately place the transition into its "end state". return; } // See if we've already queued to run a follow-up transition: if (!transitionQueued) { prevTransition.AddTransitionEndDelegate(RunFollowupTrans); } transitionQueued = true; }
protected override void OnDisable() { base.OnDisable(); // Cancel any queued transitions: if (transitionQueued) { nextTransition.RemoveTransitionEndDelegate(RunFollowupTrans); transitionQueued = false; } // Revert to our normal state, but if there isn't // an EZAnimator, then we either don't need to // revert, or we don't want to because the scene // is closing: if (EZAnimator.Exists() && !deleted) { // Temporarily disable running follow-up transitions: bool prevAFAT = alwaysFinishActiveTransition; alwaysFinishActiveTransition = false; // Cancel any running transition: if (prevTransition != null) { if (prevTransition.IsRunning()) { prevTransition.End(); } } // Restore our setting: alwaysFinishActiveTransition = prevAFAT; } prevTransition = null; }
// Sets the button's visual state to match its value. protected virtual void SetButtonState(bool suppressTransition) { // Make sure we have a mesh: if (spriteMesh == null) { return; } // Make sure we're initialized since // we might have been called as a result of // another button in our group settings its // value on Start() before we've had a cance // to Start() ourselves, meaning we may lack // important info like a valid screensize, // etc. which is necessary for sizing or else // we'll get vertices of "infinite" value // resulting in a !local.IsValid() error: if (!m_started) { return; } int prevState = (int)state; state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled; // Clamp the index just to the state indices // directly supported by the control int index = Mathf.Clamp((int)state, 0, 2); // First see if we need to postpone this state // change for when we are active: #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 if (!gameObject.activeInHierarchy) #else if (!gameObject.active) #endif { stateChangeWhileDeactivated = true; return; } this.SetState(index); this.UseStateLabel(index); // Recalculate our collider UpdateCollider(); SetLayerState(state); // End any current transition: if (prevTransition != null && prevState != (int)state) { prevTransition.StopSafe(); } StartTransition(index, prevState); // If we're suppressing transitions, end it immediately: if (suppressTransition) { if (prevTransition != null) { prevTransition.End(); } } }
// Queues a transition to play following the previous (currently-running) transition protected void QueueTransition(int newState, int prevState, bool suppressTransition) { if (deleted) return; nextTransition = transitions[newState].list[DetermineNextTransition(newState, prevState)]; nextState = (CONTROL_STATE)newState; if (suppressTransition) { prevTransition.End(); prevTransition = nextTransition; prevTransition.Start(); prevTransition.End(); // Immediately place the transition into its "end state". return; } // See if we've already queued to run a follow-up transition: if (!transitionQueued) prevTransition.AddTransitionEndDelegate(RunFollowupTrans); transitionQueued = true; }