public void StartUI() { this.gameObject.SetActive(true); m_CanvasGroup.alpha = m_StartAlpha; EventSystem.current.SetSelectedGameObject(m_BtnRestart.gameObject); DoState = DoFadeIn; }
private void DoFadeIn() { m_CanvasGroup.alpha = Mathf.Lerp(m_CanvasGroup.alpha, m_TargetAlpha, Time.deltaTime); if (m_CanvasGroup.alpha >= m_TargetAlpha - 0.01f) { m_CanvasGroup.alpha = m_TargetAlpha; DoState = null; } }
private void DoBackwardProgress() { if (currentTime > endTime) { currentTime -= Time.deltaTime * speed; if (currentTime < endTime) { currentTime = endTime; } OnProgress(); } else { if (OnTweenFinished != null) { OnTweenFinished(); } OnTween = null; this.enabled = false; } }
/// <summary> /// Play tween animation by manual setting. /// </summary> /// <param name="startPercentage">Strat percentage of animation curve setting</param> /// <param name="endPercentage">End percentage of animation curve setting</param> public void Play(float startPercentage, float endPercentage) { this.enabled = true; currentTime = startPercentage; endTime = endPercentage; speed = 1 / m_time; if (startPercentage <= endPercentage) { OnTween = DoForwardProgress; } else { OnTween = DoBackwardProgress; } if (OnTweenStart != null) { OnTweenStart(); } }