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);
                            });
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public override void OnBuildTrackContextMenu(GenericMenu menu, TrackAsset trackAsset, ITimelineState state)
 {
     Type[] allStandalonePlayableAssets = TimelineHelpers.GetAllStandalonePlayableAssets();
     Type[] array = allStandalonePlayableAssets;
     for (int i = 0; i < array.Length; i++)
     {
         Type type = array[i];
         if (!type.IsDefined(typeof(HideInMenuAttribute), true) && !type.IsDefined(typeof(IgnoreOnPlayableTrackAttribute), true))
         {
             string     displayName = TrackDrawer.GetDisplayName(type);
             GUIContent gUIContent  = new GUIContent("Add Clip/" + displayName);
             menu.AddItem(gUIContent, false, delegate(object userData)
             {
                 TimelineHelpers.CreateClipOnTrack(userData as Type, trackAsset, state);
             }, type);
         }
     }
 }