public static void AddMenuItems(GenericMenu menu, GroupTrack track) { TimelineWindow.TimelineState state = TimelineWindow.instance.state; TrackType[] array = TimelineHelpers.GetMixableTypes(); array = (from x in array orderby(!x.trackType.Assembly.FullName.Contains("UnityEngine.Sequence")) ? 1 : 0 select x).ToArray <TrackType>(); TrackType[] array2 = array; for (int i = 0; i < array2.Length; i++) { TrackType trackType = array2[i]; if (trackType.trackType != typeof(GroupTrack)) { GenericMenu.MenuFunction2 menuFunction = delegate(object e) { track.SetCollapsed(false); state.GetWindow().AddTrack((e as TrackType).trackType, track, null); TimelineTrackBaseGUI timelineTrackBaseGUI = TimelineTrackBaseGUI.FindGUITrack(track); if (timelineTrackBaseGUI != null) { TimelineWindow.instance.treeView.data.SetExpanded(timelineTrackBaseGUI, true); } }; object obj = trackType; string text = TimelineHelpers.GetTrackCategoryName(trackType); if (!string.IsNullOrEmpty(text)) { text += "/"; } menu.AddItem(new GUIContent("Add " + text + TimelineHelpers.GetTrackMenuName(trackType)), false, menuFunction, obj); } } }
public static void AddMenuItems(GenericMenu menu, GroupTrack track) { var state = TimelineWindow.instance.state; var trackTypes = TypeUtility.AllTrackTypes(); foreach (var t in trackTypes) { if (t == typeof(GroupTrack)) { continue; } GenericMenu.MenuFunction2 menuFunc = trackType => { track.SetCollapsed(false); state.GetWindow().AddTrack((System.Type)trackType, track); var uiTrack = FindGUITrack(track); if (uiTrack != null) { TimelineWindow.instance.treeView.data.SetExpanded(uiTrack, true); } }; object lastUserData = t; var category = TimelineHelpers.GetTrackCategoryName(t); if (!string.IsNullOrEmpty(category)) { category += "/"; } var content = EditorGUIUtility.TrTextContent("Add " + category + TimelineHelpers.GetTrackMenuName(t)); if (track.lockedInHierarchy) { menu.AddDisabledItem(content, false); } else { menu.AddItem(content, false, menuFunc, lastUserData); } } }