public void InstantContract() { canvasGroup.alpha = 0f; rectTransform.sizeDelta = Vector2.zero; SubmitSizeForSoftening(); m_State = 0; m_RippleCreator.OnDestroyRipple(); RippleManager.instance.ReleaseRipple(this); }
/// <summary> /// See MonoBehaviour.Update. /// </summary> void Update() { m_AnimDeltaTime = Time.realtimeSinceStartup - m_AnimStartTime; if (m_State == 1) { if (m_AnimDeltaTime <= m_AnimationDuration) { canvasGroup.alpha = Tween.QuintOut(m_CurrentAlpha, rippleData.EndAlpha, m_AnimDeltaTime, m_AnimationDuration); float size = Tween.QuintOut(m_CurrentSize, CalculateSize(), m_AnimDeltaTime, m_AnimationDuration); rectTransform.sizeDelta = new Vector2(size, size); SubmitSizeForSoftening(); if (rippleData.MoveTowardCenter) { Vector3 parentPosition = m_RippleParent.GetPositionRegardlessOfPivot(); rectTransform.position = Tween.QuintOut(m_CurrentPosition, new Vector3(parentPosition.x, parentPosition.y, m_RippleParent.position.z), m_AnimDeltaTime, m_AnimationDuration); } } else { if (m_Oscillate) { m_State = 3; m_AnimStartTime = Time.realtimeSinceStartup; m_CurrentSize = rectTransform.rect.width; m_CurrentSize *= 0.95f; } else { m_State = 0; } } } else if (m_State == 2) { if (m_AnimDeltaTime <= m_AnimationDuration * 2f) { canvasGroup.alpha = Tween.QuintOut(m_CurrentAlpha, 0f, m_AnimDeltaTime, m_AnimationDuration * 2f); float size = Tween.QuintOut(m_CurrentSize, CalculateSize(), m_AnimDeltaTime, m_AnimationDuration); rectTransform.sizeDelta = new Vector2(size, size); SubmitSizeForSoftening(); if (rippleData.MoveTowardCenter) { Vector3 parentPosition = m_RippleParent.GetPositionRegardlessOfPivot(); rectTransform.position = Tween.QuintOut(m_CurrentPosition, new Vector3(parentPosition.x, parentPosition.y, m_RippleParent.position.z), m_AnimDeltaTime, m_AnimationDuration); } } else { m_State = 0; m_RippleCreator.OnDestroyRipple(); RippleManager.instance.ReleaseRipple(this); } } else if (m_State == 3) { float size = Tween.Sin(m_CurrentSize, m_CurrentSize * 0.05f, m_AnimDeltaTime * 4); rectTransform.sizeDelta = new Vector2(size, size); SubmitSizeForSoftening(); } }