示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (phase == PoppingPhase.Opening)
        {
            float t = (Time.time - startTime) / elapseTime;
            transform.localPosition = Vector3.Lerp(startPosition, targetPosition, t);
            transform.localScale    = Vector3.Lerp(startScale, targetScale, t);

            if (t >= 1)
            {
                phase = PoppingPhase.Idle;
            }
        }
        else if (phase == PoppingPhase.Closing)
        {
            float t = (Time.time - startTime) / elapseTime;
            transform.localPosition = Vector3.Lerp(targetPosition, startPosition, t);
            transform.localScale    = Vector3.Lerp(targetScale, startScale, t);

            if (t >= 1)
            {
                if (closingCallback != null)
                {
                    closingCallback();
                }
            }
        }
    }
示例#2
0
    // Start is called before the first frame update
    void Start()
    {
        if (startPosition == Vector3.zero)
        {
            phase = PoppingPhase.Idle;
        }
        else
        {
            phase = PoppingPhase.Opening;
        }

        transform.localScale    = startScale;
        transform.localPosition = startPosition;

        startTime = Time.time;
    }
示例#3
0
 public void Close(Action callback)
 {
     startTime       = Time.time;
     closingCallback = callback;
     phase           = PoppingPhase.Closing;
 }