コード例 #1
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            base.ProcessFrame(playable, info, playerData);

            if (MainCamera == null)
            {
                return;
            }

            int       activeInputs   = 0;
            ClipInfo  clipA          = new ClipInfo();
            ClipInfo  clipB          = new ClipInfo();
            Texture2D overlayTexture = null;

            for (int i = 0; i < playable.GetInputCount(); ++i)
            {
                float weight = playable.GetInputWeight(i);
                ScriptPlayable <CameraFadePlayableBehaviour> clip = (ScriptPlayable <CameraFadePlayableBehaviour>)playable.GetInput(i);

                CameraFadePlayableBehaviour shot = clip.GetBehaviour();
                if (shot != null &&
                    shot.IsValid &&
                    playable.GetPlayState() == PlayState.Playing &&
                    weight > 0.0001f)
                {
                    clipA = clipB;

                    clipB.weight         = weight;
                    clipB.localTime      = clip.GetTime();
                    clipB.duration       = clip.GetDuration();
                    clipB.overlayTexture = shot.overlayTexture;

                    if (++activeInputs == 2)
                    {
                        break;
                    }
                }
            }

            overlayTexture = (clipB.overlayTexture != null) ? clipB.overlayTexture : clipA.overlayTexture;
            float _weight = clipB.weight;

            MainCamera.SetTimelineFadeOverride(overlayTexture, _weight);
        }