Ejemplo n.º 1
0
    //
    private IEnumerator crossFadeLayerWeight(int layer, float duration, bool enable)
    {
        Debug.Log(enable + " " + layerMixer.GetInputWeight(layer));
        //既に有効/無効になっている場合は処理しない
        if (enable && layerMixer.GetInputWeight(layer) >= 1f)
        {
            yield break;
        }
        else if (enable == false && layerMixer.GetInputWeight(layer) <= 0f)
        {
            yield break;
        }

        // 指定時間でアニメーションをブレンド
        float waitTime = Time.time + duration;

        yield return(new WaitWhile(() =>
        {
            float diff = waitTime - Time.time;
            float rate = Mathf.Clamp01(diff / duration);
            float weight = (enable) ? 1 - rate : rate;
            layerMixer.SetInputWeight(layer, weight);

            if (diff <= 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }));
    }
        public void Start(VRC_PlayableLayerControl control)
        {
            _control = control;

            _startWeight = _playableMixer.GetInputWeight(_index);
            _startTime   = Time.time;
        }