Exemple #1
0
 /// <summary>
 /// Update the track group to the current running time of the cutscene.
 /// </summary>
 /// <param name="time">The current running time</param>
 /// <param name="deltaTime">The deltaTime since the last update call</param>
 public virtual void UpdateTrackGroup(float time, float deltaTime)
 {
     TimelineTrack[] timelineTrackArr = GetTracks();
     for (int i = 0; i < timelineTrackArr.Length; i++)
     {
         TimelineTrack track = timelineTrackArr[i];
         track.UpdateTrack(time, deltaTime);
     }
 }
Exemple #2
0
 static public int UpdateTrack(IntPtr l)
 {
     try {
         CinemaDirector.TimelineTrack self = (CinemaDirector.TimelineTrack)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         self.UpdateTrack(a1, a2);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #3
0
        /// <summary>
        /// Bake the Mecanim preview data.
        /// </summary>
        public void Bake()
        {
#if PROFILE_FILE
            Profiler.BeginSample("CharacterTrackGroup.Bake");
#endif // PROFILE_FILE
            if (Actor == null || Application.isPlaying)
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return;
            }
            Animator animator = Actor.GetComponent <Animator>();
            if (animator == null)
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return;
            }

            List <RevertInfo> revertCache = new List <RevertInfo>();

            // Build the cache of revert info.
            var comps = this.GetComponentsInChildren <MonoBehaviour>();
            for (var i = 0; i < comps.Length; ++i)
            {
                MonoBehaviour mb         = comps[i];
                IRevertable   revertable = mb as IRevertable;
                if (revertable != null)
                {
                    revertCache.AddRange(revertable.CacheState());
                }
            }

            Vector3    position = Actor.transform.localPosition;
            Quaternion rotation = Actor.transform.localRotation;
            Vector3    scale    = Actor.transform.localScale;

            float frameRate  = 30;
            int   frameCount = (int)((Cutscene.Duration * frameRate) + 2);
            animator.StopPlayback();
            animator.recorderStartTime = 0;
            animator.StartRecording(frameCount);

            base.SetRunningTime(0);

            for (int i = 0; i < frameCount - 1; i++)
            {
                var tracks = GetTracks();
                for (int j = 0; j < tracks.Length; ++j)
                {
                    TimelineTrack track = tracks[j];
                    if (!(track is DialogueTrack))
                    {
                        track.UpdateTrack(i * (1.0f / frameRate), (1.0f / frameRate));
                    }
                }
                animator.Update(1.0f / frameRate);
            }
            animator.recorderStopTime = frameCount * (1.0f / frameRate);
            animator.StopRecording();
            animator.StartPlayback();

            hasBeenBaked = true;

            // Return the Actor to his initial position.
            Actor.transform.localPosition = position;
            Actor.transform.localRotation = rotation;
            Actor.transform.localScale    = scale;

            for (int i = 0; i < revertCache.Count; ++i)
            {
                RevertInfo revertable = revertCache[i];
                if (revertable != null)
                {
                    if ((revertable.EditorRevert == RevertMode.Revert && !Application.isPlaying) ||
                        (revertable.RuntimeRevert == RevertMode.Revert && Application.isPlaying))
                    {
                        revertable.Revert();
                    }
                }
            }

            base.Initialize();
#if PROFILE_FILE
            Profiler.EndSample();
#endif // PROFILE_FILE
        }