Exemplo n.º 1
0
    void Update()
    {
        if (mod == null)
        {
            mod = (MegaPointCache)GetComponent <MegaPointCache>();
        }

        if (LinkedUpdate)
        {
            DoLinkedUpdate();
        }
        else
        {
            if (mod && clips.Count > 0 && current < clips.Count)
            {
                if (t >= 0.0f)
                {
                    t += Time.deltaTime;
                    float dt = clips[current].end - clips[current].start;

                    switch (clips[current].loop)
                    {
                    case MegaRepeatMode.Loop: at = Mathf.Repeat(t, dt); break;

                    case MegaRepeatMode.PingPong: at = Mathf.PingPong(t, dt); break;

                    case MegaRepeatMode.Clamp: at = Mathf.Clamp(t, 0.0f, dt); break;
                    }

                    at += clips[current].start;
                    mod.SetAnim(at);
                }
            }
        }
    }
    void DoUpdate()
    {
        if (mod == null && modref == null)
        {
            mod    = (MegaPointCache)GetComponent <MegaPointCache>();
            modref = (MegaPointCacheRef)GetComponent <MegaPointCacheRef>();
        }

        if (mod != null || modref != null)
        {
            if (LinkedUpdate)
            {
                DoLinkedUpdate();
            }
            else
            {
                if (clips.Count > 0 && current < clips.Count)
                {
                    if (t >= 0.0f)
                    {
                        t += Time.deltaTime * clips[current].speed;
                        float dt = clips[current].end - clips[current].start;

                        switch (clips[current].loop)
                        {
                        //case MegaRepeatMode.Loop: at = Mathf.Repeat(t, dt); break;
                        case MegaRepeatMode.Loop:
                            at = Mathf.Repeat(t, Mathf.Abs(dt));
                            if (dt < 0.0f)
                            {
                                at = clips[current].start - at;
                            }
                            break;

                        case MegaRepeatMode.PingPong: at = Mathf.PingPong(t, dt); break;

                        case MegaRepeatMode.Clamp: at = Mathf.Clamp(t, 0.0f, dt); break;
                        }

                        at += clips[current].start;

                        if (mod)
                        {
                            mod.SetAnim(at);
                        }
                        else
                        {
                            modref.SetAnim(at);
                        }
                    }
                }
            }
        }
    }