Exemplo n.º 1
0
 public void UnarmForRecord(TrackAsset track)
 {
     m_ArmedTracks.Remove(TimelineUtility.GetSceneReferenceTrack(track));
     if (m_ArmedTracks.Count == 0)
         recording = false;
     track.OnRecordingUnarmed(editSequence.director);
 }
Exemplo n.º 2
0
        public TrackAsset GetArmedTrack(TrackAsset track)
        {
            TrackAsset outTrack;

            m_ArmedTracks.TryGetValue(TimelineUtility.GetSceneReferenceTrack(track), out outTrack);
            return(outTrack);
        }
Exemplo n.º 3
0
        // Only one track within a 'track' hierarchy can be armed
        public void ArmForRecord(TrackAsset track)
        {
            m_ArmedTracks[TimelineUtility.GetSceneReferenceTrack(track)] = track;
            if (track != null && !recording)
                recording = true;
            if (!recording)
                return;

            track.OnRecordingArmed(editSequence.director);
            CalculateRowRects();
        }
Exemplo n.º 4
0
        static bool DoesTrackAllowsRecording(TrackAsset track)
        {
            // if the root animation track is in auto mode, recording is not allowed
            var animTrack = TimelineUtility.GetSceneReferenceTrack(track) as AnimationTrack;

            if (animTrack != null)
            {
                return(animTrack.trackOffset != TrackOffset.Auto);
            }

            return(false);
        }
        /// <summary>
        /// Determines whether the Timeline window can enable recording mode on an AnimationTrack.
        /// For a track to support recording, it needs to have a valid scene binding,
        /// its offset mode should not be Auto and needs to be currently visible in the Timeline Window.
        /// </summary>
        /// <param name="track">The track to query.</param>
        /// <returns>True if recording can start, False otherwise.</returns>
        public static bool CanStartRecording(this AnimationTrack track)
        {
            if (track == null)
            {
                throw new ArgumentNullException(nameof(track));
            }
            if (TimelineEditor.state == null)
            {
                return(false);
            }

            var director  = TimelineEditor.inspectedDirector;
            var animTrack = TimelineUtility.GetSceneReferenceTrack(track) as AnimationTrack;

            return(animTrack != null && animTrack.trackOffset != TrackOffset.Auto &&
                   TimelineEditor.inspectedAsset == animTrack.timelineAsset &&
                   director != null && TimelineUtility.GetSceneGameObject(director, animTrack) != null);
        }
        public static TrackAsset GetSceneReferenceTrack(TrackAsset asset)
        {
            TrackAsset result;

            if (asset == null)
            {
                result = null;
            }
            else if (asset.isSubTrack)
            {
                result = TimelineUtility.GetSceneReferenceTrack(asset.parent as TrackAsset);
            }
            else
            {
                result = asset;
            }
            return(result);
        }
 public static void SetSceneGameObject(PlayableDirector director, TrackAsset asset, GameObject go)
 {
     if (!(director == null) && !(asset == null))
     {
         asset = TimelineUtility.GetSceneReferenceTrack(asset);
         IEnumerable <PlayableBinding> outputs = asset.get_outputs();
         if (outputs.Count <PlayableBinding>() != 0)
         {
             PlayableBinding playableBinding = outputs.First <PlayableBinding>();
             if (playableBinding.get_streamType() == null || playableBinding.get_sourceBindingType() == typeof(GameObject))
             {
                 TimelineHelpers.AddRequiredComponent(go, asset);
                 TimelineUtility.SetBindingInDirector(director, asset, go);
             }
             else
             {
                 TimelineUtility.SetBindingInDirector(director, asset, TimelineHelpers.AddRequiredComponent(go, asset));
             }
         }
     }
 }
        public static GameObject GetSceneGameObject(PlayableDirector director, TrackAsset asset)
        {
            GameObject result;

            if (director == null || asset == null)
            {
                result = null;
            }
            else
            {
                asset = TimelineUtility.GetSceneReferenceTrack(asset);
                GameObject gameObject = director.GetGenericBinding(asset) as GameObject;
                Component  component  = director.GetGenericBinding(asset) as Component;
                if (component != null)
                {
                    gameObject = component.get_gameObject();
                }
                result = gameObject;
            }
            return(result);
        }
Exemplo n.º 9
0
        public AnimationClip PrepareTrack(TrackAsset track, WindowState state, GameObject gameObject, out double startTime)
        {
            AnimationClip animationClip = null;

            // if we are not in clip mode, we simply use the track clip
            var animationTrack = (AnimationTrack)track;

            // ignore recording if we are in Legacy auto mode
            startTime = -1;
            var parentTrack = TimelineUtility.GetSceneReferenceTrack(track) as AnimationTrack;

            if (parentTrack != null && parentTrack.trackOffset == TrackOffset.Auto)
            {
                return(null);
            }

            if (!animationTrack.inClipMode)
            {
                var trackClip = animationTrack.GetOrCreateClip();
                startTime = trackClip.frameRate * state.editSequence.time;

                // Make the first key be at time 0 of the clip
                if (trackClip.empty)
                {
                    animationTrack.infiniteClipTimeOffset        = 0; // state.time;
                    animationTrack.infiniteClipPreExtrapolation  = TimelineClip.ClipExtrapolation.Hold;
                    animationTrack.infiniteClipPostExtrapolation = TimelineClip.ClipExtrapolation.Hold;
                }

                animationClip = trackClip;
            }
            else
            {
                TimelineClip activeClip = null;

                // if it fails, but returns no clip, we can add one.
                if (!track.FindRecordingClipAtTime(state.editSequence.time, out activeClip) && activeClip != null)
                {
                    return(null);
                }

                if (activeClip == null)
                {
                    activeClip = AddRecordableClip(track, state, state.editSequence.time);
                }

                var clip = activeClip.animationClip;

                // flags this as the clip being recorded for the track
                var clipTime = state.editSequence.time - activeClip.start;

                // if we are in the past
                if (clipTime < 0)
                {
                    Undo.RegisterCompleteObjectUndo(clip, "Record Key");
                    UndoExtensions.RegisterTrack(track, "Prepend Key");
                    ShiftAnimationClip(clip, (float)-clipTime);
                    activeClip.start     = state.editSequence.time;
                    activeClip.duration += -clipTime;
                    clipTime             = 0;
                }

                m_ClipTime         = clipTime;
                recordClip         = activeClip;
                startTime          = recordClip.ToLocalTimeUnbound(state.editSequence.time) * clip.frameRate;
                m_needRebuildRects = clip.empty;

                animationClip = clip;
            }

            m_TargetClip = animationClip;
            m_CurveCount = GetCurveCount(animationClip);
            m_TrackHasPreviewComponents = animationTrack.hasPreviewComponents;

            return(animationClip);
        }