private void Update() { if (Hovering) { m_hoverT += Time.deltaTime; float normalised = m_hoverT / 0.2f; bool done = false; if (normalised >= 1) { normalised = 1; done = true; } Vector3 size = Vector3.one; float ease = EaseOutQuart(normalised); switch (m_hoverState) { case eHoverState.animatingOn: size = Vector3.Lerp(Vector3.one, BigSize, ease); break; case eHoverState.animatingOff: size = Vector3.Lerp(BigSize, Vector3.one, ease); break; } m_rect.localScale = size; if (done) { m_hoverState = (m_hoverState == eHoverState.animatingOn) ? eHoverState.idleOn : eHoverState.idleOff; } } }
//-------------------------------------- // Public calls //-------------------------------------- public void SetHovering(bool selected) { if (selected && (m_hoverState == eHoverState.animatingOn || m_hoverState == eHoverState.idleOn)) { return; } if (!selected && (m_hoverState == eHoverState.animatingOff || m_hoverState == eHoverState.idleOff)) { return; } if (selected) { m_hoverState = eHoverState.animatingOn; } else { m_hoverState = eHoverState.animatingOff; } m_hoverT = 0f; }