Пример #1
0
        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);
                            });
                        }
                    }
                }
            }
        }