Exemple #1
0
 internal static void OnRecordingTimeChanged(this TrackAsset track, PlayableDirector director)
 {
     if (!(track == null))
     {
         AnimationClip animationClip = track.FindRecordingAnimationClipAtTime(director.get_time());
         AnimationClip activeRecordingAnimationClip = track.GetActiveRecordingAnimationClip();
         if (activeRecordingAnimationClip != animationClip)
         {
             TrackAssetRecordingExtensions.s_ActiveClips[track] = animationClip;
         }
     }
 }
Exemple #2
0
 internal static void OnRecordingArmed(this TrackAsset track, PlayableDirector director)
 {
     if (!(track == null))
     {
         AnimationClip animationClip = track.FindRecordingAnimationClipAtTime(director.get_time());
         if (!(animationClip == null))
         {
             TrackAssetRecordingExtensions.s_ActiveClips[track] = animationClip;
             track.SetShowInlineCurves(true);
         }
     }
 }
        public static void MatchPrevious(TimelineClip currentClip, Transform matchPoint, PlayableDirector director)
        {
            MatchTargetFields matchFields = TimelineAnimationUtilities.GetMatchFields(currentClip);

            if (matchFields != MatchTargetFieldConstants.None && !(matchPoint == null))
            {
                double       time         = director.get_time();
                TimelineClip previousClip = TimelineAnimationUtilities.GetPreviousClip(currentClip);
                if (previousClip != null && currentClip != previousClip)
                {
                    AnimationTrack animationTrack  = currentClip.parentTrack as AnimationTrack;
                    double         blendInDuration = currentClip.blendInDuration;
                    currentClip.blendInDuration = 0.0;
                    double blendOutDuration = previousClip.blendOutDuration;
                    previousClip.blendOutDuration = 0.0;
                    director.Stop();
                    animationTrack.RemoveClip(currentClip);
                    director.Play();
                    double num = (currentClip.start <= previousClip.end) ? currentClip.start : previousClip.end;
                    director.set_time(num - 1E-05);
                    director.Evaluate();
                    Vector3    position = matchPoint.get_position();
                    Quaternion rotation = matchPoint.get_rotation();
                    director.Stop();
                    animationTrack.AddClip(currentClip);
                    animationTrack.RemoveClip(previousClip);
                    director.Play();
                    director.set_time(currentClip.start + 1E-05);
                    director.Evaluate();
                    AnimationPlayableAsset asset = currentClip.asset as AnimationPlayableAsset;
                    TimelineAnimationUtilities.RigidTransform result = TimelineAnimationUtilities.UpdateClipOffsets(asset, animationTrack, matchPoint, position, rotation);
                    TimelineAnimationUtilities.WriteMatchFields(asset, result, matchFields);
                    currentClip.blendInDuration   = blendInDuration;
                    previousClip.blendOutDuration = blendOutDuration;
                    director.Stop();
                    animationTrack.AddClip(previousClip);
                    director.Play();
                    director.set_time(time);
                    director.Evaluate();
                }
            }
        }
        public static void ComputeClipWorldSpaceOffset(PlayableDirector director, TimelineClip clip, out Vector3 clipPositionOffset, out Quaternion clipRotationOffset)
        {
            GameObject sceneGameObject = TimelineUtility.GetSceneGameObject(director, clip.parentTrack);
            double     time            = director.get_time();
            TrackAsset parentTrack     = clip.parentTrack;

            TimelineClip[] clips = parentTrack.clips;
            director.Stop();
            for (int i = 0; i < clips.Length; i++)
            {
                parentTrack.RemoveClip(clips[i]);
            }
            parentTrack.AddClip(clip);
            double start           = clip.start;
            double blendInDuration = clip.blendInDuration;

            clip.blendInDuration = 0.0;
            clip.start           = 1.0;
            director.Play();
            director.set_time(0.0);
            director.Evaluate();
            clipPositionOffset = sceneGameObject.get_transform().get_position();
            clipRotationOffset = sceneGameObject.get_transform().get_rotation();
            AnimationPlayableAsset animationPlayableAsset = clip.asset as AnimationPlayableAsset;

            if (!(animationPlayableAsset == null))
            {
                clipPositionOffset += clipRotationOffset * animationPlayableAsset.position;
                clipRotationOffset *= animationPlayableAsset.rotation;
                director.Stop();
                clip.start           = start;
                clip.blendInDuration = blendInDuration;
                parentTrack.RemoveClip(clip);
                for (int j = 0; j < clips.Length; j++)
                {
                    parentTrack.AddClip(clips[j]);
                }
                director.Play();
                director.set_time(time);
                director.Evaluate();
            }
        }
        public static void ComputeTrackOffsets(PlayableDirector director, TimelineClip clip, out Vector3 parentPositionOffset, out Quaternion parentRotationOffset, out Vector3 positionOffset, out Quaternion rotationOffset)
        {
            GameObject sceneGameObject = TimelineUtility.GetSceneGameObject(director, clip.parentTrack);
            double     time            = director.get_time();
            TrackAsset parentTrack     = clip.parentTrack;

            TimelineClip[] clips = parentTrack.clips;
            director.Stop();
            for (int i = 0; i < clips.Length; i++)
            {
                parentTrack.RemoveClip(clips[i]);
            }
            parentTrack.AddClip(clip);
            double start           = clip.start;
            double blendInDuration = clip.blendInDuration;

            clip.blendInDuration = 0.0;
            clip.start           = 1.0;
            director.Play();
            director.set_time(1.0);
            director.Evaluate();
            positionOffset = sceneGameObject.get_transform().get_position();
            rotationOffset = sceneGameObject.get_transform().get_rotation();
            director.set_time(0.0);
            director.Evaluate();
            parentPositionOffset = sceneGameObject.get_transform().get_position();
            parentRotationOffset = sceneGameObject.get_transform().get_rotation();
            director.Stop();
            clip.start           = start;
            clip.blendInDuration = blendInDuration;
            parentTrack.RemoveClip(clip);
            for (int j = 0; j < clips.Length; j++)
            {
                parentTrack.AddClip(clips[j]);
            }
            director.Play();
            director.set_time(time);
            director.Evaluate();
        }