Пример #1
0
        protected override void OnUpdate(float time, float previousTime)
        {
            if (!Brain)
            {
                return;
            }
            int activeInputs = 0;
            CinemachineVirtualCameraBase camA = null;
            CinemachineVirtualCameraBase camB = null;
            float camWeight = 1f;

            for (int i = 0; i < clips.Count; ++i)
            {
                var shot
                    = clips[i] as CinemachineClip;
                var weight = shot.GetShotWeight(time - shot.startTime);
                if (shot.VirtualCamera != null && (shot.startTime < time && shot.endTime >= time))
                {
                    if (activeInputs == 1)
                    {
                        camB = camA;
                    }
                    camWeight = weight;
                    camA      = shot.VirtualCamera;
                    ++activeInputs;
                    if (activeInputs == 2)
                    {
                        break;
                    }
                }
            }
            Camera.SetCameras(camB, camA, camWeight);
#if UNITY_EDITOR
            Brain.SendMessage("LateUpdate");
#endif
        }