示例#1
0
    void Update()
    {
        if (m_timeToDelayStart <= 0.0)
        {
            //increment current time by DT
            m_currentTime += Time.deltaTime;

            if (!(m_currentTime > m_timeToReachDesiredScale))
            {
                //Switch as to which effect will happen
                switch (m_interpolationEffect)
                {
                case Effect.BOUNCE_IN_OUT:
                    gameObject.transform.localScale = (Vector3.one * Mathf.LerpUnclamped(0, m_desiredScale, Interpolation.BounceInOut(m_currentTime / m_timeToReachDesiredScale)));
                    break;

                case Effect.ELASTIC_IN_OUT:
                    gameObject.transform.localScale = (Vector3.one * Mathf.LerpUnclamped(0, m_desiredScale, Interpolation.ElasticInOut(m_currentTime / m_timeToReachDesiredScale)));
                    break;

                case Effect.LINEAR:
                    gameObject.transform.localScale = (Vector3.one * Mathf.LerpUnclamped(0, m_desiredScale, Interpolation.Linear(m_currentTime / m_timeToReachDesiredScale)));
                    break;

                case Effect.CIRCULAR_IN_OUT:
                    gameObject.transform.localScale = (Vector3.one * Mathf.LerpUnclamped(0, m_desiredScale, Interpolation.CircularInOut(m_currentTime / m_timeToReachDesiredScale)));
                    break;
                }
            }
        }
        else
        {
            //reduce the delay start by DT
            m_timeToDelayStart -= Time.deltaTime;
        }
    }