public static TimelineMarker DuplicateAtTime(TimelineMarker theMarker, TrackAsset track, PlayableDirector directorComponent, double newTime) { TrackAsset trackAsset = theMarker.parentTrack; if (track != null) { trackAsset = track; } ITimelineMarkerContainer timelineMarkerContainer = trackAsset as ITimelineMarkerContainer; TimelineMarker result; if (timelineMarkerContainer == null || trackAsset.timelineAsset == null) { result = null; } else if (double.IsInfinity(newTime)) { result = null; } else { result = timelineMarkerContainer.CreateMarker(theMarker.key, newTime); } return(result); }
private void CreateNewMarker(ITimelineMarkerContainer container, ITimelineState state) { string uniqueName = ObjectNames.GetUniqueName((from x in container.GetMarkers() select x.key).ToArray <string>(), "New Marker"); this.CreateExistingMarker(uniqueName, container, state); }
private void CreateExistingMarker(string key, ITimelineMarkerContainer container, ITimelineState state) { Vector3 mousePosition = (this.trackMenuContext.clipTimeCreation != TrackDrawer.TrackMenuContext.ClipTimeCreation.Mouse) ? TimelineHelpers.sInvalidMousePosition : this.trackMenuContext.mousePosition; double time = TrackDrawer.CalculateMarkerTimeForMousePosition(container as TrackAsset, state, mousePosition); TimelineUndo.PushUndo(container as Object, "Create Marker"); TimelineMarker newEvent = container.CreateMarker(key, time); TrackDrawer.SelectMarkerInInspector(state, newEvent); state.Refresh(); }
public virtual void OnBuildTrackContextMenu(GenericMenu menu, TrackAsset trackAsset, ITimelineState state) { bool flag = trackAsset is AnimationTrack || trackAsset is AudioTrack; if (flag) { List <Type> list = TimelineHelpers.GetTypesHandledByTrackType(TimelineHelpers.TrackTypeFromType(trackAsset.GetType())).ToList <Type>(); for (int i = 0; i < list.Count; i++) { Type assetType = list[i]; this.AddAddAssetMenuItem(menu, assetType, trackAsset, state); } } else if (TimelineHelpers.GetMediaTypeFromType(trackAsset.GetType()) == TimelineAsset.MediaType.Script) { Type customPlayableType = trackAsset.GetCustomPlayableType(); if (customPlayableType != null) { string displayName = TrackDrawer.GetDisplayName(customPlayableType); GUIContent gUIContent = new GUIContent("Add " + displayName + " Clip"); menu.AddItem(new GUIContent(gUIContent), false, delegate(object userData) { TimelineHelpers.CreateClipOnTrack(userData as Type, trackAsset, state); }, customPlayableType); } } ITimelineMarkerContainer markerContainer = trackAsset as ITimelineMarkerContainer; if (markerContainer != null) { menu.AddItem(TrackDrawer.Styles.newMarker, false, delegate { this.CreateNewMarker(markerContainer, state); }); IEnumerable <string> enumerable = (from x in markerContainer.GetMarkers() select x.key).Distinct <string>(); if (enumerable.Any <string>()) { using (IEnumerator <string> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { string key = enumerator.Current; menu.AddItem(new GUIContent(TrackDrawer.Styles.addMarker.get_text() + key), false, delegate { this.CreateExistingMarker(key, markerContainer, state); }); } } } } }
private int GetMarkerContainerHash() { ITimelineMarkerContainer timelineMarkerContainer = this as ITimelineMarkerContainer; int result; if (timelineMarkerContainer == null) { result = 0; } else { TimelineMarker[] markers = timelineMarkerContainer.GetMarkers(); result = ((markers != null) ? markers.Length : 0); } return(result); }
public override bool Execute(TimelineWindow.TimelineState state, TimelineMarker[] markers) { state.Stop(); for (int i = 0; i < markers.Length; i++) { TimelineMarker timelineMarker = markers[i]; ITimelineMarkerContainer timelineMarkerContainer = timelineMarker.parentTrack as ITimelineMarkerContainer; if (timelineMarkerContainer != null) { timelineMarkerContainer.RemoveMarker(timelineMarker); } } SelectionManager.Clear(); state.Refresh(true); return(true); }
private void RebuildEventsGUICache(TimelineWindow.TimelineState state) { this.m_MarkerGuiCache = new List <TimelineMarkerGUI>(); ITimelineMarkerContainer timelineMarkerContainer = base.track as ITimelineMarkerContainer; if (timelineMarkerContainer != null) { TimelineMarker[] markers = timelineMarkerContainer.GetMarkers(); for (int i = 0; i < markers.Length; i++) { TimelineMarker theMarker = markers[i]; TimelineMarkerGUI item = new TimelineMarkerGUI(theMarker, state.timeline, this); this.m_MarkerGuiCache.Add(item); this.m_ChildrenControls.Add(item); } } }
private double GetMarkerDuration() { ITimelineMarkerContainer timelineMarkerContainer = this as ITimelineMarkerContainer; double num = 0.0; if (timelineMarkerContainer != null) { TimelineMarker[] markers = timelineMarkerContainer.GetMarkers(); if (markers != null) { for (int i = 0; i < markers.Length; i++) { num = Math.Max(num, markers[i].time); } } } return(num); }
private int GetMarkerHash() { ITimelineMarkerContainer timelineMarkerContainer = this as ITimelineMarkerContainer; int num = 0; if (timelineMarkerContainer != null) { TimelineMarker[] markers = timelineMarkerContainer.GetMarkers(); if (markers != null) { for (int i = 0; i < markers.Length; i++) { num = num.CombineHash(((ITimelineItem)markers[i]).Hash()); } } } return(num); }