Пример #1
0
        internal static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, PlayableDirector director, PlayableAsset assetOwner)
        {
            var subtracks = source.GetChildTracks();

            foreach (var sub in subtracks)
            {
                var newSub = TimelineHelpers.Clone(duplicate, sub, director, assetOwner);
                duplicate.AddChild(newSub);
                RecursiveSubtrackClone(sub, newSub, director, assetOwner);

                // Call the custom editor on Create
                var customEditor = CustomTimelineEditorCache.GetTrackEditor(newSub);
                try
                {
                    customEditor.OnCreate(newSub, sub);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }

                // registration has to happen AFTER recursion
                TimelineUndo.RegisterCreatedObjectUndo(newSub, "Duplicate");
                TimelineCreateUtilities.SaveAssetIntoObject(newSub, assetOwner);
            }
        }
        internal static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, PlayableDirector director)
        {
            List <TrackAsset> subTracks = source.subTracks;

            foreach (TrackAsset current in subTracks)
            {
                TrackAsset trackAsset = TimelineHelpers.Clone(duplicate, current, director);
                duplicate.AddChild(trackAsset);
                TrackExtensions.RecursiveSubtrackClone(current, trackAsset, director);
                Undo.RegisterCreatedObjectUndo(trackAsset, "Duplicate");
                TimelineCreateUtilities.SaveAssetIntoObject(trackAsset, source);
            }
        }
        internal static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, PlayableDirector director, PlayableAsset assetOwner)
        {
            var subtracks = source.GetChildTracks();

            foreach (var sub in subtracks)
            {
                var newSub = TimelineHelpers.Clone(duplicate, sub, director, assetOwner);
                duplicate.AddChild(newSub);
                RecursiveSubtrackClone(sub, newSub, director, assetOwner);
                // registration has to happen AFTER recursion
                TimelineUndo.RegisterCreatedObjectUndo(newSub, "Duplicate");
                TimelineCreateUtilities.SaveAssetIntoObject(newSub, assetOwner);
            }
        }
        static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, PlayableAsset assetOwner)
        {
            var subtracks = source.GetChildTracks();

            foreach (var sub in subtracks)
            {
                var newSub = TimelineHelpers.Clone(duplicate, sub, sourceTable, destTable, assetOwner);
                duplicate.AddChild(newSub);
                RecursiveSubtrackClone(sub, newSub, sourceTable, destTable, assetOwner);

                // Call the custom editor on Create
                var customEditor = CustomTimelineEditorCache.GetTrackEditor(newSub);
                customEditor.OnCreate_Safe(newSub, sub);

                // registration has to happen AFTER recursion
                TimelineCreateUtilities.SaveAssetIntoObject(newSub, assetOwner);
                TimelineUndo.RegisterCreatedObjectUndo(newSub, L10n.Tr("Duplicate"));
            }
        }
        internal static bool ReparentTracks(List <TrackAsset> tracksToMove, PlayableAsset targetParent, TrackAsset insertMarker, bool insertBefore)
        {
            TrackAsset    trackAsset    = targetParent as TrackAsset;
            TimelineAsset timelineAsset = targetParent as TimelineAsset;
            bool          result;

            if (tracksToMove == null || tracksToMove.Count == 0 || (trackAsset == null && timelineAsset == null))
            {
                result = false;
            }
            else
            {
                List <TrackAsset> list = (from x in tracksToMove
                                          where x.parent != targetParent
                                          select x).ToList <TrackAsset>();
                if (insertMarker == null && !list.Any <TrackAsset>())
                {
                    result = false;
                }
                else
                {
                    List <PlayableAsset> list2 = (from x in list
                                                  select x.parent into x
                                                  where x != null
                                                  select x).Distinct <PlayableAsset>().ToList <PlayableAsset>();
                    TimelineUndo.PushUndo(targetParent, "Reparent");
                    foreach (PlayableAsset current in list2)
                    {
                        TimelineUndo.PushUndo(current, "Reparent");
                    }
                    foreach (TrackAsset current2 in list)
                    {
                        TimelineUndo.PushUndo(current2, "Reparent");
                    }
                    foreach (TrackAsset current3 in list)
                    {
                        if (current3.parent != targetParent)
                        {
                            TrackAsset    trackAsset2    = current3.parent as TrackAsset;
                            TimelineAsset timelineAsset2 = current3.parent as TimelineAsset;
                            if (timelineAsset2 != null)
                            {
                                timelineAsset2.RemoveTrack(current3);
                            }
                            else if (trackAsset2 != null)
                            {
                                trackAsset2.RemoveSubTrack(current3);
                            }
                            if (trackAsset != null)
                            {
                                trackAsset.AddChild(current3);
                                trackAsset.SetCollapsed(false);
                            }
                            else
                            {
                                timelineAsset.AddTrackInternal(current3);
                            }
                        }
                    }
                    if (insertMarker != null)
                    {
                        List <TrackAsset> allTracks = (!(trackAsset != null)) ? timelineAsset.tracks : trackAsset.subTracks;
                        TimelineUtility.ReorderTracks(allTracks, tracksToMove, insertMarker, insertBefore);
                        if (insertMarker.timelineAsset != null)
                        {
                            insertMarker.timelineAsset.Invalidate();
                        }
                    }
                    result = true;
                }
            }
            return(result);
        }