123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- using System.Collections.Generic;
- using UnityEditor.Timeline.Actions;
- using UnityEngine;
- using UnityEngine.Playables;
- using UnityEngine.Timeline;
- using Object = UnityEngine.Object;
- namespace UnityEditor.Timeline
- {
-
-
-
-
-
-
-
-
-
- public static class UndoExtensions
- {
-
-
-
-
-
-
- public static void RegisterContext(ActionContext context, string undoTitle)
- {
- using (var undo = new UndoScope(undoTitle))
- {
- undo.Add(context.tracks);
- undo.Add(context.clips, true);
- undo.Add(context.markers);
- }
- }
-
-
-
-
-
-
- public static void RegisterTimeline(TimelineAsset asset, string undoTitle)
- {
- using (var undo = new UndoScope(undoTitle))
- undo.AddObject(asset);
- }
-
-
-
-
-
-
- public static void RegisterCompleteTimeline(TimelineAsset asset, string undoTitle)
- {
- if (asset == null)
- return;
- using (var undo = new UndoScope(undoTitle))
- {
- undo.AddObject(asset);
- undo.Add(asset.flattenedTracks);
- foreach (var t in asset.flattenedTracks)
- {
- undo.Add(t.GetClips(), true);
- undo.Add(t.GetMarkers());
- }
- }
- }
-
-
-
-
-
-
- public static void RegisterTrack(TrackAsset asset, string undoTitle)
- {
- using (var undo = new UndoScope(undoTitle))
- undo.AddObject(asset);
- }
-
-
-
-
-
-
- public static void RegisterTracks(IEnumerable<TrackAsset> tracks, string undoTitle)
- {
- using (var undo = new UndoScope(undoTitle))
- undo.Add(tracks);
- }
-
-
-
-
-
-
- public static void RegisterClip(TimelineClip clip, string undoTitle, bool includePlayableAsset = true)
- {
- using (var undo = new UndoScope(undoTitle))
- {
- undo.AddClip(clip, includePlayableAsset);
- }
- }
-
-
-
-
-
- public static void RegisterPlayableAsset(PlayableAsset asset, string undoTitle)
- {
- using (var undo = new UndoScope(undoTitle))
- undo.AddObject(asset);
- }
-
-
-
-
-
-
- public static void RegisterClips(IEnumerable<TimelineClip> clips, string name, bool includePlayableAssets = true)
- {
- using (var undo = new UndoScope(name))
- undo.Add(clips, includePlayableAssets);
- }
-
-
-
-
-
- public static void RegisterMarker(IMarker marker, string undoTitle)
- {
- using (var undo = new UndoScope(undoTitle))
- {
- if (marker is Object o)
- undo.AddObject(o);
- else if (marker != null)
- undo.AddObject(marker.parent);
- }
- }
-
-
-
-
-
- public static void RegisterMarkers(IEnumerable<IMarker> markers, string undoTitle)
- {
- using (var undo = new UndoScope(undoTitle))
- undo.Add(markers);
- }
- }
- }
|