public void GenCustomMenu() { GenericMenu pm = new GenericMenu(); bool cd = (state.seqence.trackTrees.Length > 1); if (SeqenceWindow.inst.tree.AnySelect()) { pm.AddItem(EditorGUIUtility.TrTextContent("UnSelect All tracks \t #u"), false, tree.ResetSelect, false); pm.AddDisabledItem(EditorGUIUtility.TrTextContent("Select All tracks \t %s")); } else { pm.AddDisabledItem(EditorGUIUtility.TrTextContent("UnSelect All tracks \t %u")); pm.AddItem(EditorGUIUtility.TrTextContent("Select All tracks \t #s"), false, tree.ResetSelect, true); } if (cd) { pm.AddItem(EditorGUIUtility.TrTextContent("Mute All tracks \t #m"), false, MuteAll); pm.AddItem(EditorGUIUtility.TrTextContent("Lock All tracks \t #l"), false, LockAll); } else { pm.AddDisabledItem(EditorGUIUtility.TrTextContent("Mute All tracks \t #m"), false); pm.AddDisabledItem(EditorGUIUtility.TrTextContent("Lock All tracks \t #l"), false); } var paste = EditorGUIUtility.TrTextContent("Paste Track\t #p"); if (EditorTrack.clipboardTrack != null) { pm.AddItem(paste, false, PasteTrack); } else { pm.AddDisabledItem(paste, false); } pm.AddSeparator(""); pm.AddItem(EditorGUIUtility.TrTextContent("Add GroupTrack"), false, OnAddTrackItem, typeof(XGroupTrack)); var types = TypeUtilities.AllRootTrackExcMarkers(); for (int i = 0; i < types.Count; i++) { string str = types[i].ToString(); int idx = str.LastIndexOf('.'); if (idx >= 0) { int offset = idx + 1; if (str[offset] == 'X') { offset++; } str = "Add " + str.Substring(offset); } pm.AddItem(EditorGUIUtility.TrTextContent(str), false, OnAddTrackItem, types[i]); } Rect rect = new Rect(Event.current.mousePosition, new Vector2(200, 0)); pm.DropDown(rect); }
private void TrackContexMenu(Event e) { pm = new GenericMenu(); if (SeqenceWindow.inst.tree.AnySelect()) { pm.AddItem(_unselect, false, UnSelectAll, false); pm.AddDisabledItem(_select); } else { pm.AddItem(_select, false, UnSelectAll, true); pm.AddDisabledItem(_unselect); } pm.AddSeparator(""); if (allowClip && !locked) { pm.AddItem(_addclip, false, AddClip, e.mousePosition); if (HitClip(e)) { pm.AddItem(delete, false, DeleteClip, e.mousePosition); } else { pm.AddDisabledItem(delete, false); } } else { pm.AddDisabledItem(_addclip, false); pm.AddDisabledItem(delete, false); } pm.AddItem(EditorGUIUtility.TrTextContent("Delete Track\t #t"), false, DeleteTrack); if (track.mute) { pm.AddItem(EditorGUIUtility.TrTextContent("UnMute Track \t "), false, () => SetTrackFlag(TrackMode.Mute, false)); } else { pm.AddItem(EditorGUIUtility.TrTextContent("Mute Track \t"), false, () => SetTrackFlag(TrackMode.Mute, true)); } if (locked) { pm.AddItem(EditorGUIUtility.TrTextContent("UnLock Track \t #l"), false, () => SetTrackFlag(TrackMode.Lock, false)); } else { pm.AddItem(EditorGUIUtility.TrTextContent("Lock Track \t #l"), false, () => SetTrackFlag(TrackMode.Lock, true)); } if (select) { pm.AddItem(EditorGUIUtility.TrTextContent("UnSelect Track \t #s"), false, SelectTrack, false); } else { pm.AddItem(EditorGUIUtility.TrTextContent("Select Track \t #s"), false, SelectTrack, true); } if (track.cloneable) { pm.AddItem(copy, false, CopyTrack); } else { pm.AddDisabledItem(copy, false); } if (clipboardTrack != null) { pm.AddItem(paste, false, PasteTrack); } else { pm.AddDisabledItem(paste, false); } if (actions != null) { pm.AddSeparator(""); for (int i = 0; i < actions.Count; i++) { var at = actions[i]; if (!locked) { pm.AddItem(EditorGUIUtility.TrTextContent(at.desc), at.@on, at.fun, at.arg); } } } pm.AddSeparator(""); var marks = TypeUtilities.GetBelongMarks(track.AssetType); for (int i = 0; i < marks.Count; i++) { var mark = marks[i]; string str = mark.ToString(); int idx = str.LastIndexOf('.'); str = str.Substring(idx + 1); var ct = EditorGUIUtility.TrTextContent("Add " + str); MarkAction action = new MarkAction() { type = mark, posX = e.mousePosition.x }; if (!locked) { pm.AddItem(ct, false, AddMark, action); } } pm.ShowAsContext(); e.Use(); }
public static EditorTrack GetTrack(XTrack track) { return((EditorTrack)TypeUtilities.InitEObject(track)); }