public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var left = position; left.xMax -= 40; var right = position; right.xMin = left.xMax + 2; EditorGUI.PropertyField(left, property); if (GUI.Button(right, "List") == true) { var menu = new GenericMenu(); if (LeanLocalization.Instance != null) { for (var j = 0; j < LeanLocalization.Instance.Languages.Count; j++) { var language = LeanLocalization.Instance.Languages[j]; menu.AddItem(new GUIContent(language), property.stringValue == language, () => { property.stringValue = language; property.serializedObject.ApplyModifiedProperties(); }); } } if (menu.GetItemCount() > 0) { menu.DropDown(right); } else { Debug.LogWarning("Your scene doesn't contain any languages, so the language name list couldn't be created."); } } }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(string.Empty); } if (base.parent.window.showMode == ShowMode.MainWindow) { menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Maximize), view); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Maximize")); } menu.AddItem(EditorGUIUtility.TextContent("Close Tab"), false, new GenericMenu.MenuFunction2(this.Close), view); menu.AddSeparator(string.Empty); System.Type[] paneTypes = base.GetPaneTypes(); GUIContent content = EditorGUIUtility.TextContent("Add Tab"); foreach (System.Type type in paneTypes) { if (type != null) { GUIContent content2; content2 = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(type)) { text = content.text + "/" + content2.text }; menu.AddItem(content2, false, new GenericMenu.MenuFunction2(this.AddTabToHere), type); } } }
static void DoLockPropertiesMenu(GenericMenu menu, bool lockValue, Object[] targets) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } // Lock menu.AddItem(Styles.lockContent, !lockValue, () => { LockProperties(lockValue, targets); }); }
private static void ShowBusPopupMenu(int effectIndex, AudioMixerGroupController group, List <AudioMixerGroupController> allGroups, Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap, AudioMixerEffectController effect, Rect buttonRect) { GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent("None"), false, new GenericMenu.MenuFunction2(AudioMixerChannelStripView.ConnectSendPopupCallback), new AudioMixerChannelStripView.ConnectSendContext(effect, null)); genericMenu.AddSeparator(string.Empty); AudioMixerChannelStripView.AddMenuItemsForReturns(genericMenu, string.Empty, effectIndex, group, allGroups, effectMap, effect, true); if (genericMenu.GetItemCount() == 2) { genericMenu.AddDisabledItem(new GUIContent("No valid Receive targets found")); } genericMenu.DropDown(buttonRect); }
protected virtual void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow window) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } if (Unsupported.IsDeveloperMode()) { menu.AddItem(EditorGUIUtility.TrTextContent("Inspect Window", null, null), false, new GenericMenu.MenuFunction2(this.Inspect), window); menu.AddItem(EditorGUIUtility.TrTextContent("Inspect View", null, null), false, new GenericMenu.MenuFunction2(this.Inspect), window.m_Parent); menu.AddItem(EditorGUIUtility.TrTextContent("Reload Window _f5", null, null), false, new GenericMenu.MenuFunction2(this.Reload), window); menu.AddSeparator(""); } }
private static void ShowBusPopupMenu(int effectIndex, AudioMixerGroupController group, List <AudioMixerGroupController> allGroups, Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap, AudioMixerEffectController effect, Rect buttonRect) { GenericMenu pm = new GenericMenu(); pm.AddItem(EditorGUIUtility.TrTextContent("None"), false, AudioMixerChannelStripView.ConnectSendPopupCallback, new AudioMixerChannelStripView.ConnectSendContext(effect, null)); pm.AddSeparator(""); AudioMixerChannelStripView.AddMenuItemsForReturns(pm, string.Empty, effectIndex, group, allGroups, effectMap, effect, true); if (pm.GetItemCount() == 2) { pm.AddDisabledItem(EditorGUIUtility.TrTextContent("No valid Receive targets found")); } pm.DropDown(buttonRect); }
protected virtual void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow window) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } if (window && Unsupported.IsDeveloperMode()) { menu.AddItem(EditorGUIUtility.TrTextContent("Inspect Window"), false, Inspect, window); menu.AddItem(EditorGUIUtility.TrTextContent("Inspect View"), false, Inspect, window.m_Parent); menu.AddItem(EditorGUIUtility.TrTextContent("Reload Window _f5"), false, Reload, window); menu.AddSeparator(""); } }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) menu.AddSeparator(string.Empty); menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(this.parent is SplitView), new GenericMenu.MenuFunction2(this.Unmaximize), (object) view); menu.AddDisabledItem(EditorGUIUtility.TextContent("Close Tab")); menu.AddSeparator(string.Empty); System.Type[] paneTypes = this.GetPaneTypes(); GUIContent guiContent = EditorGUIUtility.TextContent("Add Tab"); foreach (System.Type t in paneTypes) { if (t != null) { GUIContent content = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(t)); content.text = guiContent.text + "/" + content.text; menu.AddDisabledItem(content); } } }
static void DoRegularMenu(GenericMenu menu, bool isOverriden, Object[] targets) { var singleEditing = targets.Length == 1; if (isOverriden) { HandleApplyRevert(menu, singleEditing, targets); } if (singleEditing && capturedProperties.Count == 1) { HandleCopyPaste(menu); } DisplayMode displayMode = GetDisplayMode(targets); if (displayMode == DisplayMode.Material) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } var shader = (targets[0] as Material).shader; GenericMenu.MenuFunction func = () => ResetMaterialProperties(capturedProperties, shader); if ((AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(shader)) as ShaderImporter) == null) { foreach (var property in capturedProperties) { if (property.type == PropType.Texture) { func = null; break; } } } menu.AddItem(Styles.resetContent, false, func); } else if (displayMode == DisplayMode.Variant) { HandleRevertAll(menu, singleEditing, targets); } }
private static void ShowBusPopupMenu(int effectIndex, AudioMixerGroupController group, List <AudioMixerGroupController> allGroups, Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap, AudioMixerEffectController effect, Rect buttonRect) { GenericMenu genericMenu = new GenericMenu(); GenericMenu arg_3A_0 = genericMenu; GUIContent arg_3A_1 = EditorGUIUtility.TrTextContent("None", null, null); bool arg_3A_2 = false; if (AudioMixerEffectView.< > f__mg$cache0 == null) { AudioMixerEffectView.< > f__mg$cache0 = new GenericMenu.MenuFunction2(AudioMixerChannelStripView.ConnectSendPopupCallback); } arg_3A_0.AddItem(arg_3A_1, arg_3A_2, AudioMixerEffectView.< > f__mg$cache0, new AudioMixerChannelStripView.ConnectSendContext(effect, null)); genericMenu.AddSeparator(""); AudioMixerChannelStripView.AddMenuItemsForReturns(genericMenu, string.Empty, effectIndex, group, allGroups, effectMap, effect, true); if (genericMenu.GetItemCount() == 2) { genericMenu.AddDisabledItem(EditorGUIUtility.TrTextContent("No valid Receive targets found", null, null)); } genericMenu.DropDown(buttonRect); }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Unmaximize), view); menu.AddDisabledItem(EditorGUIUtility.TextContent("Close Tab")); menu.AddSeparator(""); Type[] paneTypes = base.GetPaneTypes(); GUIContent content = EditorGUIUtility.TextContent("Add Tab"); foreach (Type type in paneTypes) { if (type != null) { GUIContent content2 = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(type)); content2.text = content.text + "/" + content2.text; menu.AddDisabledItem(content2); } } }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } if (base.parent.window.showMode == ShowMode.MainWindow) { menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Maximize), view); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Maximize")); } bool flag = base.window.showMode != ShowMode.MainWindow || this.AllowTabAction(); if (flag) { menu.AddItem(EditorGUIUtility.TextContent("Close Tab"), false, new GenericMenu.MenuFunction2(this.Close), view); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Close Tab")); } menu.AddSeparator(""); Type[] paneTypes = base.GetPaneTypes(); GUIContent gUIContent = EditorGUIUtility.TextContent("Add Tab"); Type[] array = paneTypes; for (int i = 0; i < array.Length; i++) { Type type = array[i]; if (type != null) { GUIContent gUIContent2 = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(type)); gUIContent2.text = gUIContent.text + "/" + gUIContent2.text; menu.AddItem(gUIContent2, false, new GenericMenu.MenuFunction2(this.AddTabToHere), type); } } }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(string.Empty); } menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(this.parent is SplitView), new GenericMenu.MenuFunction2(this.Unmaximize), (object)view); menu.AddDisabledItem(EditorGUIUtility.TextContent("Close Tab")); menu.AddSeparator(string.Empty); System.Type[] paneTypes = this.GetPaneTypes(); GUIContent guiContent = EditorGUIUtility.TextContent("Add Tab"); foreach (System.Type t in paneTypes) { if (t != null) { GUIContent content = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(t)); content.text = guiContent.text + "/" + content.text; menu.AddDisabledItem(content); } } }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(string.Empty); } menu.AddItem(EditorGUIUtility.TextContent("DockAreaMaximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Unmaximize), view); menu.AddDisabledItem(EditorGUIUtility.TextContent("DockAreaCloseTab")); menu.AddSeparator(string.Empty); Type[] paneTypes = base.GetPaneTypes(); GUIContent gUIContent = EditorGUIUtility.TextContent("DockAreaAddTab"); Type[] array = paneTypes; for (int i = 0; i < array.Length; i++) { Type type = array[i]; if (type != null) { GUIContent gUIContent2 = new GUIContent(EditorGUIUtility.TextContent(type.ToString())); gUIContent2.text = gUIContent.text + "/" + gUIContent2.text; menu.AddDisabledItem(gUIContent2); } } }
static void HandleRevertAll(GenericMenu menu, bool singleEditing, Object[] targets) { foreach (Material target in targets) { if (target.overrideCount != 0) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } menu.AddItem(Styles.revertAllContent, false, () => { string targetName = singleEditing ? targets[0].name : targets.Length + " Materials"; Undo.RecordObjects(targets, "Revert all overrides of " + targetName); foreach (Material target in targets) { target.RevertAllPropertyOverrides(); } }); break; } } }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(string.Empty); } menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Unmaximize), view); menu.AddDisabledItem(EditorGUIUtility.TextContent("Close Tab")); menu.AddSeparator(string.Empty); Type[] paneTypes = base.GetPaneTypes(); GUIContent gUIContent = EditorGUIUtility.TextContent("Add Tab"); Type[] array = paneTypes; for (int i = 0; i < array.Length; i++) { Type type = array[i]; if (type != null) { GUIContent gUIContent2 = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(type)); gUIContent2.text = gUIContent.text + "/" + gUIContent2.text; menu.AddDisabledItem(gUIContent2); } } }
protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow view) { if (menu.GetItemCount() != 0) { menu.AddSeparator(""); } if (base.parent.window.showMode == ShowMode.MainWindow) { menu.AddItem(EditorGUIUtility.TextContent("Maximize"), !(base.parent is SplitView), new GenericMenu.MenuFunction2(this.Maximize), view); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Maximize")); } if ((base.window.showMode != ShowMode.MainWindow) || (this.GetMainWindowPaneCount() > 1)) { menu.AddItem(EditorGUIUtility.TextContent("Close Tab"), false, new GenericMenu.MenuFunction2(this.Close), view); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("Close Tab")); } menu.AddSeparator(""); System.Type[] paneTypes = base.GetPaneTypes(); GUIContent content = EditorGUIUtility.TextContent("Add Tab"); foreach (System.Type type in paneTypes) { if (type != null) { GUIContent content2 = new GUIContent(EditorWindow.GetLocalizedTitleContentFromType(type)); content2.text = content.text + "/" + content2.text; menu.AddItem(content2, false, new GenericMenu.MenuFunction2(this.AddTabToHere), type); } } }
/// <summary> /// Invoked to generate context menu for list item. /// </summary> /// <param name="menu">Menu which can be populated.</param> /// <param name="itemIndex">Zero-based index of item which was right-clicked.</param> /// <param name="adaptor">Reorderable list adaptor.</param> protected virtual void AddItemsToMenu(GenericMenu menu, int itemIndex, IReorderableListAdaptor adaptor) { if ((Flags & ReorderableListFlags.DisableReordering) == 0) { if (itemIndex > 0) menu.AddItem(CommandMoveToTop, false, DefaultContextHandler, CommandMoveToTop); else menu.AddDisabledItem(CommandMoveToTop); if (itemIndex + 1 < adaptor.Count) menu.AddItem(CommandMoveToBottom, false, DefaultContextHandler, CommandMoveToBottom); else menu.AddDisabledItem(CommandMoveToBottom); if (HasAddButton) { menu.AddSeparator(""); menu.AddItem(CommandInsertAbove, false, DefaultContextHandler, CommandInsertAbove); menu.AddItem(CommandInsertBelow, false, DefaultContextHandler, CommandInsertBelow); if ((Flags & ReorderableListFlags.DisableDuplicateCommand) == 0) menu.AddItem(CommandDuplicate, false, DefaultContextHandler, CommandDuplicate); } } if (HasRemoveButtons) { if (menu.GetItemCount() > 0) menu.AddSeparator(""); menu.AddItem(CommandRemove, false, DefaultContextHandler, CommandRemove); menu.AddSeparator(""); menu.AddItem(CommandClearAll, false, DefaultContextHandler, CommandClearAll); } }
private void ShowContextMenu(int controlID, int itemIndex, IReorderableListAdaptor adaptor) { GenericMenu menu = new GenericMenu(); s_ContextControlID = controlID; s_ContextItemIndex = itemIndex; AddItemsToMenu(menu, itemIndex, adaptor); if (menu.GetItemCount() > 0) menu.ShowAsContext(); }
private void DoPopupMenu(EditorWindow console) { var listView = consoleListViewField.GetValue(console); int listViewRow = listView != null ? (int) listViewStateRowField.GetValue(listView) : -1; if (listViewRow < 0) return; string text = (string)consoleActiveTextField.GetValue(console); if (string.IsNullOrEmpty(text)) return; GenericMenu codeViewPopupMenu = new GenericMenu(); string[] lines = text.Split('\n'); foreach (string line in lines) { int atAssetsIndex = line.IndexOf("(at Assets/"); if (atAssetsIndex < 0) continue; int functionNameEnd = line.IndexOf('('); if (functionNameEnd < 0) continue; string functionName = line.Substring(0, functionNameEnd).TrimEnd(' '); int lineIndex = line.LastIndexOf(':'); if (lineIndex <= atAssetsIndex) continue; int atLine = 0; for (int i = lineIndex + 1; i < line.Length; ++i) { char c = line[i]; if (c < '0' || c > '9') break; atLine = atLine * 10 + (c - '0'); } atAssetsIndex += "(at ".Length; string assetPath = line.Substring(atAssetsIndex, lineIndex - atAssetsIndex); string scriptName = assetPath.Substring(assetPath.LastIndexOf('/') + 1); string guid = AssetDatabase.AssetPathToGUID(assetPath); if (!string.IsNullOrEmpty(guid)) { codeViewPopupMenu.AddItem( new GUIContent(scriptName + " - " + functionName.Replace(':', '.') + ", line " + atLine), false, () => FGCodeWindow.OpenAssetInTab(guid, atLine)); } } if (codeViewPopupMenu.GetItemCount() > 0) codeViewPopupMenu.ShowAsContext(); }
void DoTrackContextMenu(Event e, Rect clipsPosRect, float cursorTime, System.Action action, System.Action <Track> onDragUpdated, System.Action <Track, float> onDragPerform) { if (e.type == EventType.ContextClick && clipsPosRect.Contains(e.mousePosition)) { var attachableTypeInfos = new List <EditorTools.TypeMetaInfo>(); foreach (var info in EditorTools.GetTypeMetaDerivedFrom(typeof(Clip), Prefs.isOld)) { if (info.attachableTypes != null && !info.attachableTypes.Contains(this.GetType())) { continue; } if (info.type != typeof(Clip)) { attachableTypeInfos.Add(info); } } var menu = new UnityEditor.GenericMenu(); if (attachableTypeInfos.Count > 0) { foreach (var _info in attachableTypeInfos) { var info = _info; var tName = info.name; menu.AddItem(new GUIContent(tName), false, () => { var clip = ReflectionTools.CreateInstance(_info.type) as Clip; clip.startTime = cursorTime; AddNode(clip); CutsceneUtility.selectedObject = clip; if (action != null) { action(); } }); } e.Use(); } if (CutsceneUtility.CanPastClip(attachableTypeInfos)) { menu.AddItem(new GUIContent("粘贴"), false, () => { CutsceneUtility.PasteClip(this, cursorTime); }); } if (menu.GetItemCount() > 0) { menu.ShowAsContext(); } else { menu = null; } } if (clipsPosRect.Contains(e.mousePosition) && e.type == EventType.DragUpdated) { if (onDragUpdated != null) { onDragUpdated(this); } } if (clipsPosRect.Contains(e.mousePosition) && e.type == EventType.DragPerform) { if (onDragPerform != null) { onDragPerform(this, cursorTime); } //for (int i = 0; i < DragAndDrop.objectReferences.Length; i++) //{ // var o = DragAndDrop.objectReferences[i]; // if (o is AnimationClip && this is SkillAnimationTrack) // { // var aniClip = new SKillAnimationEvent(); // AddNode(aniClip); // aniClip.startTime = cursorTime; // aniClip.length = (o as AnimationClip).length; // aniClip.animationClip = o as AnimationClip; // if (action != null) action(); // CutsceneUtility.selectedObject = aniClip; // } //} SortClips(); } }
private static void ShowPopup(Event evt, UTNodeEditorModel model) { var menu = new GenericMenu (); if (!model.HasPlan) { menu.AddDisabledItem (new GUIContent ("Please select an automation plan.")); menu.ShowAsContext (); return; } var hotNode = GetNodeUnderMouse (model, evt.mousePosition); var hotConnector = GetConnectorUnderMouse (model, evt.mousePosition); var data = new NodeEventData (evt, model, hotConnector); if (hotNode == null && hotConnector == null) { #if UTOMATE_DEMO if (!model.CanAddEntriesToPlan) { menu.AddDisabledItem (new GUIContent ("You cannot add any more entries in the demo version.")); } else { #endif menu.AddItem (new GUIContent ("Add Action Entry"), false, AddActionNode, data); menu.AddItem (new GUIContent ("Add Decision Entry"), false, AddDecisionNode, data); menu.AddItem (new GUIContent ("Add For-Each Entry"), false, AddForEachNode, data); menu.AddItem (new GUIContent ("Add For-Each File Entry"), false, AddForEachFileNode, data); menu.AddItem (new GUIContent ("Add Sub-Plan Entry"), false, AddPlanNode, data); menu.AddItem (new GUIContent ("Add Note"), false, AddNote, data); #if UTOMATE_DEMO } #endif } if (hotNode != null) { if (!model.SelectedNodes.Contains (hotNode)) { model.SelectNode (hotNode, UTNodeEditorModel.SelectionMode.Replace); } if (menu.GetItemCount () > 0) { menu.AddSeparator (""); } var isMultiSelection = model.SelectedNodes.Count > 1; if (!model.IsFirstNode (hotNode) && !isMultiSelection) { menu.AddItem (new GUIContent ("Set As First Entry"), false, SetAsFirstNode, data); } menu.AddItem (new GUIContent (isMultiSelection ? "Delete Entries" : "Delete Entry"), false, DeleteNode, data); } if (hotConnector != null && hotConnector.isConnected) { if (menu.GetItemCount () > 0) { menu.AddSeparator (""); } menu.AddItem (new GUIContent ("Delete Connection"), false, DeleteConnection, data); } menu.ShowAsContext (); }
private static void ShowBusPopupMenu(int effectIndex, AudioMixerGroupController group, List<AudioMixerGroupController> allGroups, Dictionary<AudioMixerEffectController, AudioMixerGroupController> effectMap, AudioMixerEffectController effect, Rect buttonRect) { GenericMenu pm = new GenericMenu(); pm.AddItem(new GUIContent("None"), false, new GenericMenu.MenuFunction2(AudioMixerChannelStripView.ConnectSendPopupCallback), (object) new AudioMixerChannelStripView.ConnectSendContext(effect, (AudioMixerEffectController) null)); pm.AddSeparator(string.Empty); AudioMixerChannelStripView.AddMenuItemsForReturns(pm, string.Empty, effectIndex, group, allGroups, effectMap, effect, true); if (pm.GetItemCount() == 2) pm.AddDisabledItem(new GUIContent("No valid Receive targets found")); pm.DropDown(buttonRect); }
private void DoPopupMenu(EditorWindow console) { var listView = consoleListViewField.GetValue(console); int listViewRow = listView != null ? (int) listViewStateRowField.GetValue(listView) : -1; if (listViewRow < 0) return; string text = (string)consoleActiveTextField.GetValue(console); if (string.IsNullOrEmpty(text)) return; GenericMenu codeViewPopupMenu = new GenericMenu(); string[] lines = text.Split('\n'); foreach (string line in lines) { int atAssetsIndex = line.IndexOf("(at Assets/"); if (atAssetsIndex < 0) continue; int functionNameEnd = line.IndexOf('('); if (functionNameEnd < 0) continue; string functionName = line.Substring(0, functionNameEnd).TrimEnd(' '); int lineIndex = line.LastIndexOf(':'); if (lineIndex <= atAssetsIndex) continue; int atLine = 0; for (int i = lineIndex + 1; i < line.Length; ++i) { char c = line[i]; if (c < '0' || c > '9') break; atLine = atLine * 10 + (c - '0'); } atAssetsIndex += "(at ".Length; string assetPath = line.Substring(atAssetsIndex, lineIndex - atAssetsIndex); string scriptName = assetPath.Substring(assetPath.LastIndexOf('/') + 1); string guid = AssetDatabase.AssetPathToGUID(assetPath); if (!string.IsNullOrEmpty(guid)) { codeViewPopupMenu.AddItem( new GUIContent(scriptName + " - " + functionName.Replace(':', '.') + ", line " + atLine), false, () => { if (openLogEntriesInSi2) { FGCodeWindow.addRecentLocationForNextAsset = true; FGCodeWindow.OpenAssetInTab(guid, atLine); } else { FGCodeWindow.openInExternalIDE = true; AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath(assetPath), atLine); } }); } } if (codeViewPopupMenu.GetItemCount() > 0) { codeViewPopupMenu.AddSeparator(string.Empty); codeViewPopupMenu.AddItem( new GUIContent("Open Call-Stack Entries in Script Inspector"), openLogEntriesInSi2, () => { openLogEntriesInSi2 = !openLogEntriesInSi2; } ); GUIUtility.hotControl = 0; codeViewPopupMenu.ShowAsContext(); GUIUtility.ExitGUI(); } }
private void HandleAnchorContext(int controlID, JointHelpers.AnchorBias bias, AnchoredJoint2D joint, Joint2DSettingsBase joint2DSettings, Vector2 anchorPosition, Rigidbody2D connectedBody) { EditorHelpers.ContextClick(controlID, () => { var menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent(joint.GetType() .Name)); menu.AddSeparator(""); if (WantsLocking()) { menu.AddItem(new GUIContent("Lock Anchors", GetAnchorLockTooltip()), joint2DSettings.lockAnchors, () => { EditorHelpers.RecordUndo( joint2DSettings.lockAnchors ? "Unlock Anchors" : "Lock Anchors", joint2DSettings, joint); if (!joint2DSettings.lockAnchors) { ReAlignAnchors(joint, bias); } joint2DSettings.lockAnchors = !joint2DSettings.lockAnchors; EditorUtility.SetDirty(joint2DSettings); EditorUtility.SetDirty(joint); }); } { var otherBias = JointHelpers.GetOppositeBias(bias); var otherPosition = JointHelpers.GetAnchorPosition(joint, otherBias); if (Vector2.Distance(otherPosition, anchorPosition) <= AnchorEpsilon) { menu.AddDisabledItem(new GUIContent("Bring other anchor here")); } else { menu.AddItem(new GUIContent("Bring other anchor here"), false, () => { EditorHelpers.RecordUndo("Move Joint Anchor", joint); JointHelpers.SetWorldAnchorPosition(joint, anchorPosition, otherBias); EditorUtility.SetDirty(joint); }); } } menu.AddItem(new GUIContent("Enable Collision", "Should rigid bodies connected with this joint collide?"), joint.enableCollision, () => { EditorHelpers.RecordUndo("Move Joint Anchor", joint); joint.enableCollision = !joint.enableCollision; EditorUtility.SetDirty(joint); }); menu.AddSeparator(""); var itemCount = menu.GetItemCount(); ExtraMenuItems(menu, joint); if (itemCount != menu.GetItemCount()) { menu.AddSeparator(""); } if (connectedBody) { var connectedBodyName = connectedBody.name; var selectConnectedBodyContent = new GUIContent(string.Format("Select '{0}'", connectedBodyName)); if (isCreatedByTarget) { menu.AddDisabledItem(selectConnectedBodyContent); } else { menu.AddItem(selectConnectedBodyContent, false, () => { Selection.activeGameObject = connectedBody.gameObject; }); } menu.AddItem(new GUIContent(string.Format("Move ownership to '{0}'", connectedBodyName)), false, () => { var connectedObject = connectedBody.gameObject; var cloneJoint = Undo.AddComponent(connectedObject, joint.GetType()) as AnchoredJoint2D; if (!cloneJoint) { return; } EditorUtility.CopySerialized(joint, cloneJoint); cloneJoint.connectedBody = joint.GetComponent<Rigidbody2D>(); JointHelpers.SetWorldAnchorPosition(cloneJoint, JointHelpers.GetAnchorPosition(joint, JointHelpers.AnchorBias.Main), JointHelpers.AnchorBias.Connected); JointHelpers.SetWorldAnchorPosition(cloneJoint, JointHelpers.GetAnchorPosition(joint, JointHelpers.AnchorBias.Connected), JointHelpers.AnchorBias.Main); var jointSettings = SettingsHelper.GetOrCreate(joint); var cloneSettings = Undo.AddComponent(connectedObject, jointSettings.GetType()) as Joint2DSettingsBase; if (cloneSettings == null) { return; } cloneSettings.hideFlags = HideFlags.HideInInspector; EditorUtility.CopySerialized(jointSettings, cloneSettings); cloneSettings.Setup(cloneJoint); cloneSettings.SetOffset(JointHelpers.AnchorBias.Main, jointSettings.GetOffset(JointHelpers.AnchorBias.Connected)); cloneSettings.SetOffset(JointHelpers.AnchorBias.Connected, jointSettings.GetOffset(JointHelpers.AnchorBias.Main)); if (!Selection.Contains(connectedObject)) { var selectedObjects = new List<Object>(Selection.objects) {connectedObject}; if (selectedObjects.Contains(joint.gameObject)) { selectedObjects.Remove(joint.gameObject); } Selection.objects = selectedObjects.ToArray(); } Undo.DestroyObjectImmediate(joint); OwnershipMoved(cloneJoint); }); menu.AddItem(new GUIContent("Disconnect from '" + connectedBodyName + "'"), false, () => { var worldConnectedPosition = JointHelpers.GetConnectedAnchorPosition(joint); using (new Modification("Disconnect from connected body", joint)) { joint.connectedBody = null; JointHelpers.SetWorldConnectedAnchorPosition(joint, worldConnectedPosition); } }); } else { menu.AddDisabledItem(new GUIContent("Select connected body")); menu.AddDisabledItem(new GUIContent("Move ownership to connected body")); menu.AddDisabledItem(new GUIContent("Disconnect from connected body")); } menu.AddItem(new GUIContent("Delete " + joint.GetType() .Name), false, () => Undo.DestroyObjectImmediate(joint)); menu.ShowAsContext(); }); }
private void ShowReplaceHistory() { #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 string suffix = " _"; #else string suffix = ""; #endif GenericMenu menu = new GenericMenu(); if (replaceText != initialFindText && initialFindText.Trim() != "" && initialFindText.IndexOfAny(new [] {'_', '/'}) < 0) menu.AddItem(new GUIContent(initialFindText + suffix), false, SelectReplaceHistory, initialFindText); for (var i = 0; i < replaceHistory.Length && replaceHistory[i] != null; i++) if (replaceText != replaceHistory[i] && replaceHistory[i].IndexOfAny(new [] {'_', '/'}) < 0) menu.AddItem(new GUIContent(replaceHistory[i] + suffix), false, SelectReplaceHistory, replaceHistory[i]); if (menu.GetItemCount() > 0) menu.DropDown(new Rect(14f, 96f, Screen.width - 10f, 18f)); Event.current.Use(); }
private static void DoPropertyContextMenu(SerializedProperty property) { GenericMenu menu = new GenericMenu(); SerializedProperty property1 = property.serializedObject.FindProperty(property.propertyPath); ScriptAttributeUtility.GetHandler(property).AddMenuItems(property, menu); if (property.hasMultipleDifferentValues && !property.hasVisibleChildren) TargetChoiceHandler.AddSetToValueOfTargetMenuItems(menu, property1, new TargetChoiceHandler.TargetChoiceMenuFunction(TargetChoiceHandler.SetToValueOfTarget)); if (property.serializedObject.targetObjects.Length == 1 && property.isInstantiatedPrefab) menu.AddItem(EditorGUIUtility.TextContent("Revert Value to Prefab"), false, new GenericMenu.MenuFunction2(TargetChoiceHandler.SetPrefabOverride), (object) property1); if (property.propertyPath.LastIndexOf(']') == property.propertyPath.Length - 1) { if (menu.GetItemCount() > 0) menu.AddSeparator(string.Empty); menu.AddItem(EditorGUIUtility.TextContent("Duplicate Array Element"), false, new GenericMenu.MenuFunction2(TargetChoiceHandler.DuplicateArrayElement), (object) property1); menu.AddItem(EditorGUIUtility.TextContent("Delete Array Element"), false, new GenericMenu.MenuFunction2(TargetChoiceHandler.DeleteArrayElement), (object) property1); } if (Event.current.shift) { if (menu.GetItemCount() > 0) menu.AddSeparator(string.Empty); menu.AddItem(EditorGUIUtility.TextContent("Print Property Path"), false, (GenericMenu.MenuFunction2) (e => Debug.Log((object) ((SerializedProperty) e).propertyPath)), (object) property1); } Event.current.Use(); if (menu.GetItemCount() == 0) return; menu.ShowAsContext(); }