Exemple #1
0
    void Update()
    {
        if (morph == null)
        {
            morph = (MegaMorphBase)GetComponent <MegaMorphBase>();
        }

        if (LinkedUpdate)
        {
            DoLinkedUpdate();
        }
        else
        {
            if (morph && 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;
                    morph.SetAnim(at);
                }
            }
        }
    }
    void Update()
    {
        if (MultipleMorphs)
        {
            if (morphs == null)
            {
                morphs = GetComponentsInChildren <MegaMorphBase>();
            }
        }
        else
        {
            if (morph == null)
            {
                morph = (MegaMorphBase)GetComponent <MegaMorphBase>();
            }
        }

        if (LinkedUpdate)
        {
            DoLinkedUpdate();
        }
        else
        {
            //if ( morph && clips.Count > 0 && current < clips.Count )
            if (clips.Count > 0 && current < clips.Count)
            {
                UpdatePlayingClips();
                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.PingPong:   at = Mathf.PingPong(t, dt);             break;

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

                    at += clips[current].start;

                    if (MultipleMorphs)
                    {
                        if (morphs != null)
                        {
                            for (int i = 0; i < morphs.Length; i++)
                            {
                                morphs[i].SetAnim(at);
                            }
                        }
                    }
                    else
                    {
                        if (morph)
                        {
                            morph.SetAnim(at);
                        }
                    }
                }
            }
        }
    }