private void GroupMenu() { var e = Event.current; if (e.type == EventType.ContextClick) { if (area.Contains(e.mousePosition)) { GenericMenu pm = new GenericMenu(); 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 st = idx + 1; if (str[idx + 1] == 'X') { st++; } str = "Add " + str.Substring(st); } pm.AddItem(EditorGUIUtility.TrTextContent(str), false, OnAddTrackItem, types[i]); } var del = EditorGUIUtility.TrTextContent("Delete Track"); var dels = EditorGUIUtility.TrTextContent("Delete Tracks (Childs Include)"); pm.AddSeparator(""); if (track.childs == null || track.childs.Length <= 0) { pm.AddItem(del, false, DeleteTrack); pm.AddDisabledItem(dels, false); } else { pm.AddDisabledItem(del, false); pm.AddItem(dels, false, DeleteTrack); } pm.ShowAsContext(); e.Use(); } } }
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); }