internal 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; if (trackAssetParent != null) { trackAssetParent.AddChild(asset); } else { AddTrackInternal(asset); } return(asset); }
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); }