Example #1
0
    private bool Crossfade(int index, float time)
    {
        for (int i = 0; i < m_States.Count; i++)
        {
            StateInfo state = m_States[i];
            if (state == null)
            {
                continue;
            }

            if (state.index == index)
            {
                m_States.EnableState(index);
            }

            if (state.enabled == false)
            {
                continue;
            }

            float targetWeight = state.index == index ? 1.0f : 0.0f;
            SetupLerp(state, targetWeight, time);
        }

        return(true);
    }
Example #2
0
    /// <summary>
    /// 在time時間內,將當前動畫fade成指定state。
    /// </summary>
    private bool Crossfade(int index, float time)
    {
        for (int i = 0; i < m_States.Count; i++)
        {
            StateInfo state = m_States[i];
            if (state == null)
            {
                continue;
            }

            // 找指定index的state
            if (state.index == index)
            {
                m_States.EnableState(index);
            }
            // 如果是關閉的state就skip
            if (state.enabled == false)
            {
                continue;
            }
            // 如果是指定的index,則target weight是1.0,其餘的則是0
            float targetWeight = state.index == index ? 1.0f : 0.0f;
            // 設定state內的fading相關參數
            SetupLerp(state, targetWeight, time);
        }

        return(true);
    }
Example #3
0
    public bool Play(int index, float animTime = 0.0f, float currentTime = 0.0f)
    {
        StateInfo doState = m_States[index];

        // 실행중이면 빠르게 스킵
        if (doState.enabled)
        {
            return(false);
        }
        if (animTime != 0.0f)
        {
            doState.playable.SetSpeed(doState.clip.length / animTime);
        }

        for (int i = 0; i < m_States.Count; i++)
        {
            StateInfo state = m_States[i];
            if (state == null)
            {
                continue;
            }

            if (state.index == index)
            {
                m_States.EnableState(i, currentTime);
                m_States.SetInputWeight(i, 1f);
            }
            else
            {
                DoStop(i);
            }
        }

        return(true);
    }
Example #4
0
    private bool Play(int index)
    {
        for (int i = 0; i < m_States.Count; i++)
        {
            StateInfo state = m_States[i];
            if (state.index == index)
            {
                m_States.EnableState(i);
                m_States.SetInputWeight(i, 1f);
            }
            else
            {
                DoStop(i);
            }
        }

        return(true);
    }