示例#1
0
 public bool IsTrackRecordable(TrackAsset track)
 {
     // A track with animated parameters can always be recorded to
     return(IsArmedForRecord(track) || track.HasAnyAnimatableParameters());
 }
示例#2
0
 internal static void SetShowInlineCurves(this TrackAsset track, bool inlineOn)
 {
     TimelineWindowViewPrefs.SetShowInlineCurves(track, inlineOn);
 }
 public CinemachineTrackManager(TimelineAsset _timeline)
 {
     timeline     = _timeline;
     currentTrack = timeline.CreateTrack <CinemachineTrack>(null, "film_track");
 }
示例#4
0
 internal static void SetCollapsed(this TrackAsset track, bool collapsed)
 {
     TimelineWindowViewPrefs.SetTrackCollapsed(track, collapsed);
 }
示例#5
0
 internal static void SetShowMarkers(this TrackAsset track, bool collapsed)
 {
     TimelineWindowViewPrefs.SetTrackShowMarkers(track, collapsed);
 }
示例#6
0
 public static double FindClipInsertionTime(TimelineClip clip, TrackAsset track)
 {
     return(ClipExtensions.FindClipInsertionTime(clip, track.clips));
 }
示例#7
0
        // Reparents a list of tracks to a new parent
        //  the new parent cannot be null (has to be track asset or sequence)
        //  the insertAfter can be null (will not reorder)
        internal static bool ReparentTracks(List <TrackAsset> tracksToMove, PlayableAsset targetParent,
                                            TrackAsset insertMarker = null, bool insertBefore = false)
        {
            var targetParentTrack   = targetParent as TrackAsset;
            var targetSequenceTrack = targetParent as TimelineAsset;

            if (tracksToMove == null || tracksToMove.Count == 0 || (targetParentTrack == null && targetSequenceTrack == null))
            {
                return(false);
            }

            // invalid parent type on a track
            if (targetParentTrack != null && tracksToMove.Any(x => !TimelineCreateUtilities.ValidateParentTrack(targetParentTrack, x.GetType())))
            {
                return(false);
            }

            // no valid tracks means this is simply a rearrangement
            var validTracks = tracksToMove.Where(x => x.parent != targetParent).ToList();

            if (insertMarker == null && !validTracks.Any())
            {
                return(false);
            }

            var parents = validTracks.Select(x => x.parent).Where(x => x != null).Distinct().ToList();

            // push the current state of the tracks that will change
            foreach (var p in parents)
            {
                TimelineUndo.PushUndo(p, "Reparent");
            }
            foreach (var t in validTracks)
            {
                TimelineUndo.PushUndo(t, "Reparent");
            }
            TimelineUndo.PushUndo(targetParent, "Reparent");

            // need to reparent tracks first, before moving them.
            foreach (var t in validTracks)
            {
                if (t.parent != targetParent)
                {
                    TrackAsset    toMoveParent   = t.parent as TrackAsset;
                    TimelineAsset toMoveTimeline = t.parent as TimelineAsset;
                    if (toMoveTimeline != null)
                    {
                        toMoveTimeline.RemoveTrack(t);
                    }
                    else if (toMoveParent != null)
                    {
                        toMoveParent.RemoveSubTrack(t);
                    }

                    if (targetParentTrack != null)
                    {
                        targetParentTrack.AddChild(t);
                        targetParentTrack.SetCollapsed(false);
                    }
                    else
                    {
                        targetSequenceTrack.AddTrackInternal(t);
                    }
                }
            }


            if (insertMarker != null)
            {
                // re-ordering track. This is using internal APIs, so invalidation of the tracks must be done manually to avoid
                //  cache mismatches
                var children = targetParentTrack != null ? targetParentTrack.subTracksObjects : targetSequenceTrack.trackObjects;
                TimelineUtility.ReorderTracks(children, tracksToMove, insertMarker, insertBefore);
                if (targetParentTrack != null)
                {
                    targetParentTrack.Invalidate();
                }
                if (insertMarker.timelineAsset != null)
                {
                    insertMarker.timelineAsset.Invalidate();
                }
            }

            return(true);
        }
示例#8
0
 public static TimelineClip[] GetClipsInSpanInTrack(TrackAsset track, double start, double end)
 {
     return(GetClipsInTrack(track, clip => clip.start >= start && clip.end <= end));
 }
 public void Grab(IEnumerable <ITimelineItem> items, TrackAsset referenceTrack)
 {
     Grab(items, referenceTrack, Vector2.zero);
 }
示例#10
0
 public static TimelineClip[] GetClipsBeforeTimeInTrack(TrackAsset track, double time)
 {
     return(GetClipsInTrack(track, clip => clip.end < time));
 }
示例#11
0
 public static TimelineClip[] GetClipsAfterTimeInTrack(TrackAsset track, double time)
 {
     return(GetClipsInTrack(track, clip => clip.start > time));
 }
示例#12
0
 public static TimelineClip[] GetClipsAtTimeInTrack(TrackAsset track, double time)
 {
     return(GetClipsInTrack(track, clip => clip.start <= time && clip.end > time));
 }
示例#13
0
 public static TimelineClip[] GetAllClipsInTrack(TrackAsset track, double time)
 {
     return(GetClipsInTrack(track, clip => true));
 }
示例#14
0
 public bool IsArmedForRecord(TrackAsset track)
 {
     return(track == GetArmedTrack(track));
 }
 /// <summary>
 /// Queries whether the children of the Track are currently visible in the Timeline Editor.
 /// </summary>
 /// <param name="track">The track asset to query.</param>
 /// <returns>True if the track is collapsed and false otherwise.</returns>
 public static bool IsCollapsed(this TrackAsset track)
 {
     return(TimelineWindowViewPrefs.IsTrackCollapsed(track));
 }
        public void Grab(IEnumerable <ITimelineItem> items, TrackAsset referenceTrack, Vector2 mousePosition)
        {
            if (items == null)
            {
                return;
            }

            items = items.ToArray(); // Cache enumeration result

            if (!items.Any())
            {
                return;
            }

            m_GrabbedModalUndoGroup = Undo.GetCurrentGroup();

            var trackItems      = items.GroupBy(c => c.parentTrack).ToArray();
            var trackItemsCount = trackItems.Length;
            var tracks          = items.Select(c => c.parentTrack).Where(x => x != null).Distinct();

            movingItems = new MovingItems[trackItemsCount];

            allowTrackSwitch = trackItemsCount == 1 && !trackItems.SelectMany(x => x).Any(x => x is MarkerItem); // For now, track switch is only supported when all items are on the same track and there are no items
            foreach (var sourceTrack in tracks)
            {
                // one push per track handles all the clips on the track
                TimelineUndo.PushUndo(sourceTrack, "Move Items");

                // push all markers on the track because of ripple
                foreach (var marker in sourceTrack.GetMarkers().OfType <ScriptableObject>())
                {
                    TimelineUndo.PushUndo(marker, "Move Items");
                }
            }

            for (var i = 0; i < trackItemsCount; ++i)
            {
                var track        = trackItems[i].Key;
                var grabbedItems = new MovingItems(m_State, track, trackItems[i].ToArray(), referenceTrack, mousePosition, allowTrackSwitch);
                movingItems[i] = grabbedItems;
            }

            m_LeftMostMovingItems  = null;
            m_RightMostMovingItems = null;

            foreach (var grabbedTrackItems in movingItems)
            {
                if (m_LeftMostMovingItems == null || m_LeftMostMovingItems.start > grabbedTrackItems.start)
                {
                    m_LeftMostMovingItems = grabbedTrackItems;
                }

                if (m_RightMostMovingItems == null || m_RightMostMovingItems.end < grabbedTrackItems.end)
                {
                    m_RightMostMovingItems = grabbedTrackItems;
                }
            }

            m_ItemGUIs   = new HashSet <TimelineItemGUI>();
            m_ItemsGroup = new ItemsGroup(items);

            foreach (var item in items)
            {
                m_ItemGUIs.Add(item.gui);
            }

            targetTrack = referenceTrack;

            EditMode.BeginMove(this);
            m_Grabbing = true;
        }
 internal static void UnarmForRecord(this TrackAsset track)
 {
     TimelineWindow.instance.state.UnarmForRecord(track);
 }
示例#18
0
        private void OnGUI()
        {
            GUILayout.BeginVertical();
            //
            GUILayout.BeginHorizontal();
            //区域B 展示区域
            int  x         = 0;
            int  y         = 0;
            int  size      = 60;
            int  padding   = 10;
            int  maxCount  = 600 / (size + padding);
            int  count     = 0;
            Rect rect      = Rect.zero;
            Rect labelRect = Rect.zero;

            GUILayout.BeginArea(new Rect(padding, padding, 600, 600));
            GUILayout.BeginScrollView(new Vector2(300, 0),
                                      GUILayout.Width(600), GUILayout.ExpandHeight(true));

            var nodeInfos = BGMSwitchHelper.config.topics;

            if (nodeInfos != null)
            {
                foreach (var nodeInfo in nodeInfos)
                {
                    if (nodeInfo == null)
                    {
                        return;
                    }
                    rect = new Rect(x, y, size, size);
                    string topicname = nodeInfo.topicname;
                    if (GUI.Button(rect, topicname))
                    {
                        System.Random random = new System.Random();
                        int           rat    = random.Next(nodeInfo.items.Count);
                        Debug.Log("rat: " + rat);
                        string    id        = nodeInfo.items[rat].id;
                        AudioClip audioclip = Resources.Load <AudioClip>(id);

                        if (audioclip == null)
                        {
                            Debug.LogError("audioclip is null. path: " + id);
                        }
                        else
                        {
                            TimelineAsset     timelineAsset = BGMSwitchHelper.bgmPlayableDirector.playableAsset as TimelineAsset;
                            List <TrackAsset> lstTrackAsset = timelineAsset.GetRootTracks().ToList <TrackAsset>();
                            for (int i = 0; i < lstTrackAsset.Count; i++)
                            {
                                TrackAsset trackAsset = timelineAsset.GetRootTrack(i);
                                timelineAsset.DeleteTrack(trackAsset);
                            }
                            var track = timelineAsset.CreateTrack <AudioTrack>(null, "bgmTrack");
                            BGMSwitchHelper.bgmPlayableDirector.SetGenericBinding(track, BGMSwitchHelper.BMGMgrGo);


                            var clip = track.CreateClip(audioclip);
                            clip.displayName = audioclip.name;
                            AudioPlayableAsset clipasset = clip.asset as AudioPlayableAsset;
                            clipasset.loop = true;
                            AssetDatabase.SaveAssets();
                        }

                        Close();
                    }

                    x += size + padding;
                    count++;
                    if ((count + 1) % maxCount == 0)
                    {
                        x  = 0;
                        y += size + padding;
                    }
                }
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();
            GUILayout.EndHorizontal();

//             if (GUILayout.Button("Generate"))
//             {
//
//             }


            GUILayout.EndVertical();
        }
示例#19
0
        internal static TrackAsset Duplicate(this TrackAsset track, PlayableDirector director,
                                             TimelineAsset destinationTimeline = null)
        {
            if (track == null)
            {
                return(null);
            }

            // if the destination is us, clear to avoid bad parenting (case 919421)
            if (destinationTimeline == track.timelineAsset)
            {
                destinationTimeline = null;
            }

            var timelineParent = track.parent as TimelineAsset;
            var trackParent    = track.parent as TrackAsset;

            if (timelineParent == null && trackParent == null)
            {
                Debug.LogWarning("Cannot duplicate track because it is not parented to known type");
                return(null);
            }

            // Determine who the final parent is. If we are pasting into another track, it's always the timeline.
            //  Otherwise it's the original parent
            PlayableAsset finalParent = destinationTimeline != null ? destinationTimeline : track.parent;

            // grab the list of tracks to generate a name from (923360) to get the list of names
            // no need to do this part recursively
            var finalTrackParent   = finalParent as TrackAsset;
            var finalTimelineAsset = finalParent as TimelineAsset;
            var otherTracks        = (finalTimelineAsset != null) ? finalTimelineAsset.trackObjects : finalTrackParent.subTracksObjects;

            // Important to create the new objects before pushing the original undo, or redo breaks the
            //  sequence
            var newTrack = TimelineHelpers.Clone(finalParent, track, director, finalParent);

            newTrack.name = TimelineCreateUtilities.GenerateUniqueActorName(otherTracks, newTrack.name);

            RecursiveSubtrackClone(track, newTrack, director, finalParent);
            TimelineUndo.RegisterCreatedObjectUndo(newTrack, "Duplicate");
            TimelineCreateUtilities.SaveAssetIntoObject(newTrack, finalParent);
            TimelineUndo.PushUndo(finalParent, "Duplicate");

            if (destinationTimeline != null) // other timeline
            {
                destinationTimeline.AddTrackInternal(newTrack);
            }
            else if (timelineParent != null) // this timeline, no parent
            {
                ReparentTracks(new List <TrackAsset> {
                    newTrack
                }, timelineParent, timelineParent.GetRootTracks().Last(), false);
            }
            else // this timeline, with parent
            {
                trackParent.AddChild(newTrack);
            }

            // Call the custom editor. this check prevents the call when copying to the clipboard
            if (destinationTimeline == null || destinationTimeline == TimelineEditor.inspectedAsset)
            {
                var customEditor = CustomTimelineEditorCache.GetTrackEditor(newTrack);
                try
                {
                    customEditor.OnCreate(newTrack, track);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

            return(newTrack);
        }
        private TimelineGroupGUI CreateItem(TrackAsset a, ref Dictionary <TrackAsset, TimelineGroupGUI> tree, List <TrackAsset> selectedRows, TreeViewItem parentTreeViewItem)
        {
            TimelineGroupGUI result;

            if (a == null)
            {
                result = null;
            }
            else
            {
                if (tree == null)
                {
                    throw new ArgumentNullException("tree");
                }
                if (selectedRows == null)
                {
                    throw new ArgumentNullException("selectedRows");
                }
                if (tree.ContainsKey(a))
                {
                    result = tree[a];
                }
                else
                {
                    TimelineTrackBaseGUI timelineTrackBaseGUI = parentTreeViewItem as TimelineTrackBaseGUI;
                    if (selectedRows.Contains(a.parent as TrackAsset))
                    {
                        timelineTrackBaseGUI = this.CreateItem(a.parent as TrackAsset, ref tree, selectedRows, parentTreeViewItem);
                    }
                    int num = -1;
                    if (timelineTrackBaseGUI != null)
                    {
                        num = timelineTrackBaseGUI.get_depth();
                    }
                    num++;
                    TimelineGroupGUI timelineGroupGUI;
                    if (a.GetType() != TimelineHelpers.GroupTrackType.trackType)
                    {
                        timelineGroupGUI = new TimelineTrackGUI(this.m_TreeView, this.m_ParentGUI, a.GetInstanceID(), num, timelineTrackBaseGUI, a.get_name(), a);
                    }
                    else
                    {
                        timelineGroupGUI = new TimelineGroupGUI(this.m_TreeView, this.m_ParentGUI, a.GetInstanceID(), num, timelineTrackBaseGUI, a.get_name(), a, false);
                    }
                    this.allTrackGuis.Add(timelineGroupGUI);
                    if (timelineTrackBaseGUI != null)
                    {
                        if (timelineTrackBaseGUI.get_children() == null)
                        {
                            timelineTrackBaseGUI.set_children(new List <TreeViewItem>());
                        }
                        timelineTrackBaseGUI.get_children().Add(timelineGroupGUI);
                    }
                    else
                    {
                        this.m_RootItem = timelineGroupGUI;
                        this.SetExpanded(this.m_RootItem, true);
                    }
                    tree[a] = timelineGroupGUI;
                    AnimationTrack animationTrack = timelineGroupGUI.track as AnimationTrack;
                    bool           flag           = animationTrack != null && animationTrack.ShouldShowInfiniteClipEditor();
                    if (flag)
                    {
                        if (timelineGroupGUI.get_children() == null)
                        {
                            timelineGroupGUI.set_children(new List <TreeViewItem>());
                        }
                    }
                    else
                    {
                        bool flag2 = false;
                        for (int num2 = 0; num2 != timelineGroupGUI.track.clips.Length; num2++)
                        {
                            AnimationClip animationClip  = timelineGroupGUI.track.clips[num2].curves;
                            AnimationClip animationClip2 = timelineGroupGUI.track.clips[num2].animationClip;
                            if (animationClip != null && animationClip.get_empty())
                            {
                                animationClip = null;
                            }
                            if (animationClip2 != null && animationClip2.get_empty())
                            {
                                animationClip2 = null;
                            }
                            if (animationClip2 != null && (animationClip2.get_hideFlags() & 8) != null)
                            {
                                animationClip2 = null;
                            }
                            if (!timelineGroupGUI.track.clips[num2].recordable)
                            {
                                animationClip2 = null;
                            }
                            flag2 = (animationClip != null || animationClip2 != null);
                            if (flag2)
                            {
                                break;
                            }
                        }
                        if (flag2)
                        {
                            if (timelineGroupGUI.get_children() == null)
                            {
                                timelineGroupGUI.set_children(new List <TreeViewItem>());
                            }
                        }
                    }
                    if (a.subTracks != null)
                    {
                        for (int i = 0; i < a.subTracks.Count; i++)
                        {
                            this.CreateItem(a.subTracks[i], ref tree, selectedRows, timelineGroupGUI);
                        }
                    }
                    result = timelineGroupGUI;
                }
            }
            return(result);
        }
示例#21
0
 internal static bool GetCollapsed(this TrackAsset track)
 {
     return(TimelineWindowViewPrefs.IsTrackCollapsed(track));
 }
示例#22
0
        public static IEnumerable <IMarker> CloneMarkersToParent(IEnumerable <IMarker> markers, TrackAsset parent)
        {
            if (!markers.Any())
            {
                return(Enumerable.Empty <IMarker>());
            }
            var clonedMarkers = new List <IMarker>();

            foreach (var marker in markers)
            {
                clonedMarkers.Add(CloneMarkerToParent(marker, parent));
            }
            return(clonedMarkers);
        }
示例#23
0
 internal static bool GetShowMarkers(this TrackAsset track)
 {
     return(TimelineWindowViewPrefs.IsShowMarkers(track));
 }
示例#24
0
 internal static void OnRecordingUnarmed(this TrackAsset track, PlayableDirector director)
 {
     TrackAssetRecordingExtensions.s_ActiveClips.Remove(track);
 }
示例#25
0
 internal static bool GetShowInlineCurves(this TrackAsset track)
 {
     return(TimelineWindowViewPrefs.GetShowInlineCurves(track));
 }
示例#26
0
        private static bool ValidateClipDrag(TrackAsset target, TimelineClip clip)
        {
            TrackAsset parentTrack = clip.parentTrack;

            return(!target.locked && target.mediaType == parentTrack.mediaType);
        }
示例#27
0
 public static void ComputeBlendsFromOverlaps(this TrackAsset asset)
 {
     ComputeBlendsFromOverlaps(asset.clips);
 }
 public virtual void SetTrackAsset(TrackAsset trackAsset, PlayableDirector playableDirector)
 {
     _trackAsset     = trackAsset;
     _director       = playableDirector;
     _currentBinding = null;
 }
 public PlayableTrackManager(TimelineAsset _timeline, string trackName)
 {
     name         = trackName;
     timeline     = _timeline;
     currentTrack = timeline.CreateTrack <PlayableTrack>(null, name + trackNum.ToString());
 }
示例#30
0
        public TimelineTrackGUI(TreeViewController tv, TimelineTreeViewGUI w, int id, int depth, TreeViewItem parent, string displayName, TrackAsset sequenceActor)
            : base(tv, w, id, depth, parent, displayName, sequenceActor, false)
        {
            AnimationTrack animationTrack = sequenceActor as AnimationTrack;

            if (animationTrack != null)
            {
                m_InfiniteTrackDrawer = new InfiniteTrackDrawer(new AnimationTrackKeyDataSource(animationTrack));
            }
            else if (sequenceActor.HasAnyAnimatableParameters() && !sequenceActor.clips.Any())
            {
                m_InfiniteTrackDrawer = new InfiniteTrackDrawer(new TrackPropertyCurvesDataSource(sequenceActor));
            }

            UpdateInfiniteClipEditor(w.TimelineWindow);

            var bindings = track.outputs.ToArray();

            m_TrackDrawData.m_HasBinding = bindings.Length > 0;
            if (m_TrackDrawData.m_HasBinding)
            {
                m_TrackDrawData.m_Binding = bindings[0];
            }
            m_TrackDrawData.m_IsSubTrack      = IsSubTrack();
            m_TrackDrawData.m_AllowsRecording = DoesTrackAllowsRecording(sequenceActor);
            m_DefaultTrackIcon = TrackResourceCache.GetTrackIcon(track);


            m_TrackEditor = CustomTimelineEditorCache.GetTrackEditor(sequenceActor);

            try
            {
                m_TrackDrawOptions = m_TrackEditor.GetTrackOptions(track, null);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_TrackDrawOptions = CustomTimelineEditorCache.GetDefaultTrackEditor().GetTrackOptions(track, null);
            }

            m_TrackDrawOptions.errorText = null; // explicitly setting to null for an uninitialized state

            RebuildGUICacheIfNecessary();
        }