public IMarker CreateMarker(Type type, double time, TrackAsset owner) { if (!typeof(ScriptableObject).IsAssignableFrom(type) || !typeof(IMarker).IsAssignableFrom(type)) { throw new InvalidOperationException( "The requested type needs to inherit from ScriptableObject and implement IMarker"); } if (!owner.supportsNotifications && typeof(INotification).IsAssignableFrom(type)) { throw new InvalidOperationException( "Markers implementing the INotification interface cannot be added on tracks that do not support notifications"); } var markerSO = ScriptableObject.CreateInstance(type); var marker = (IMarker)markerSO; marker.time = time; TimelineCreateUtilities.SaveAssetIntoObject(markerSO, owner); TimelineUndo.RegisterCreatedObjectUndo(markerSO, "Create " + type.Name); TimelineUndo.PushUndo(owner, "Create " + type.Name); Add(markerSO); marker.Initialize(owner); return marker; }
TrackAsset AllocateTrack(TrackAsset trackAssetParent, string trackName, Type trackType) { if (trackAssetParent != null && trackAssetParent.timelineAsset != this) { throw new InvalidOperationException("Addtrack cannot parent to a track not in the Timeline"); } if (!typeof(TrackAsset).IsAssignableFrom(trackType)) { throw new InvalidOperationException("Supplied type must be a track asset"); } var asset = (TrackAsset)CreateInstance(trackType); asset.name = trackName; const string createTrackUndoName = "Create Track"; PlayableAsset parent = trackAssetParent != null ? trackAssetParent as PlayableAsset : this; TimelineCreateUtilities.SaveAssetIntoObject(asset, parent); TimelineUndo.RegisterCreatedObjectUndo(asset, createTrackUndoName); TimelineUndo.PushUndo(parent, createTrackUndoName); if (trackAssetParent != null) { trackAssetParent.AddChild(asset); } else //TimelineAsset is the parent { AddTrackInternal(asset); } return(asset); }
internal TimelineClip CreateClipOfType(Type requestedType) { if (!ValidateClipType(requestedType)) throw new System.InvalidOperationException("Clips of type " + requestedType + " are not permitted on tracks of type " + GetType()); var playableAsset = CreateInstance(requestedType); if (playableAsset == null) { throw new System.InvalidOperationException("Could not create an instance of the ScriptableObject type " + requestedType.Name); } playableAsset.name = requestedType.Name; TimelineCreateUtilities.SaveAssetIntoObject(playableAsset, this); TimelineUndo.RegisterCreatedObjectUndo(playableAsset, "Create Clip"); return CreateClipFromAsset(playableAsset); }
public IMarker CreateMarker(Type type, double time, TrackAsset owner) { if (!typeof(ScriptableObject).IsAssignableFrom(type) || !typeof(IMarker).IsAssignableFrom(type)) { throw new InvalidOperationException( "The requested type needs to inherit from ScriptableObject and implement IMarker"); } var markerSO = ScriptableObject.CreateInstance(type); var marker = (IMarker)markerSO; marker.time = time; TimelineCreateUtilities.SaveAssetIntoObject(markerSO, owner); TimelineUndo.RegisterCreatedObjectUndo(markerSO, "Create " + type.Name); TimelineUndo.PushUndo(owner, "Create " + type.Name); Add(markerSO); marker.Initialize(owner); return(marker); }
public static AnimationClip CreateAnimationClipForTrack(string name, TrackAsset track, bool isLegacy) { var timelineAsset = track != null ? track.timelineAsset : null; var trackFlags = track != null ? track.hideFlags : HideFlags.None; var curves = new AnimationClip { legacy = isLegacy, name = name, frameRate = timelineAsset == null ? TimelineAsset.EditorSettings.kDefaultFps : timelineAsset.editorSettings.fps }; SaveAssetIntoObject(curves, timelineAsset); curves.hideFlags = trackFlags & ~HideFlags.HideInHierarchy; // Never hide in hierarchy TimelineUndo.RegisterCreatedObjectUndo(curves, "Create Curves"); return(curves); }