/// <summary> /// Hides the objective UI. Will handle re-firings without issue. /// </summary> public void Hide() { if (_currentState == InternalShowState.Hidden || _currentState == InternalShowState.Hiding) return; _currentState = InternalShowState.Hiding; StartCoroutine("InternalHide"); }
// public methods /// <summary> /// Shows the objective UI. Will handle re-firings without issue. /// </summary> public void Show() { // prevent re-firings if (_currentState == InternalShowState.Shown || _currentState == InternalShowState.Showing) return; _currentState = InternalShowState.Showing; StartCoroutine("InternalShow"); }
// public methods public void Show() { if (_currentState == InternalShowState.Shown || _currentState == InternalShowState.Showing) { return; } _currentState = InternalShowState.Showing; StartCoroutine("InternalShow"); }
/// <summary> /// Controls the hide animation of the objective UI. /// </summary> IEnumerator InternalHide() { while (PercentShown > 0) { yield return new WaitForEndOfFrame(); // if Show was called during the show animation, cancel this animation if (_currentState != InternalShowState.Hiding) yield break; PercentShown -= PercentDelta(m_hideTime); } _currentState = InternalShowState.Hidden; }
// internal coroutines /// <summary> /// Controls the show animation of the objective UI. /// </summary> IEnumerator InternalShow() { while (PercentShown < 1) { yield return new WaitForEndOfFrame(); // if Hide was called during the show animation, cancel this animation if (_currentState != InternalShowState.Showing) yield break; PercentShown += PercentDelta(m_showTime); } _currentState = InternalShowState.Shown; }
IEnumerator InternalHide() { while (PercentShown > 0) { yield return(new WaitForEndOfFrame()); if (_currentState != InternalShowState.Hiding) { yield break; } PercentShown -= PercentDelta(m_hideTime); } _currentState = InternalShowState.Hidden; }
// internal coroutines IEnumerator InternalShow() { while (PercentShown < 1) { yield return(new WaitForEndOfFrame()); if (_currentState != InternalShowState.Showing) { yield break; } PercentShown += PercentDelta(m_showTime); } _currentState = InternalShowState.Shown; }
void Awake() { _objectiveImage = gameObject.GetComponent<Image>(); _objectiveImage.material.SetFloat("_FlashAmount", 0.5f); // init default state switch (m_defaultState) { case ShowState.Show: PercentShown = 1; _currentState = InternalShowState.Shown; break; case ShowState.Hide: PercentShown = 0; _currentState = InternalShowState.Hidden; break; } }