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);
        }
        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);
                            });
                        }
                    }
                }
            }
        }
Example #3
0
        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);
        }
Example #4
0
        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);
                }
            }
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }