当前位置: 首页>>代码示例>>C#>>正文


C# GenericMenu.AddItem方法代码示例

本文整理汇总了C#中UnityEditor.GenericMenu.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# GenericMenu.AddItem方法的具体用法?C# GenericMenu.AddItem怎么用?C# GenericMenu.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEditor.GenericMenu的用法示例。


在下文中一共展示了GenericMenu.AddItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddDefaultItemsToMenu

 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);
         }
     }
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:30,代码来源:DockArea.cs

示例2: ContextMenu

 private void ContextMenu(Model instance)
 {
     var menu = new GenericMenu();
     menu.AddItem(new GUIContent("New"), false, New);
     if (instance != null) {
         menu.AddItem(new GUIContent("Edit"), false, ShowEditWindow, instance);
     } else {
         menu.AddDisabledItem(new GUIContent("Edit"));
     }
     menu.AddSeparator("");
     if (instance != null) {
         menu.AddItem(new GUIContent("Copy"), false, Copy, instance);
     } else {
         menu.AddDisabledItem(new GUIContent("Copy"));
     }
     if (CanPaste()) {
         menu.AddItem(new GUIContent("Paste"), false, Paste);
     } else {
         menu.AddDisabledItem(new GUIContent("Paste"));
     }
     if (instance != null) {
         menu.AddItem(new GUIContent("Delete"), false, Delete, instance);
     } else {
         menu.AddDisabledItem(new GUIContent("Delete"));
     }
     menu.ShowAsContext();
 }
开发者ID:alasdairhurst,项目名称:ELB,代码行数:27,代码来源:ModelList.cs

示例3: CreateVCContextMenu

        public static void CreateVCContextMenu(ref GenericMenu menu, string assetPath, Object instance = null)
        {
            if (VCUtility.ValidAssetPath(assetPath))
            {
                bool ready = VCCommands.Instance.Ready;
                if (ready)
                {
                    var assetStatus = VCCommands.Instance.GetAssetStatus(assetPath);
                    if (instance && ObjectUtilities.ChangesStoredInScene(instance)) assetPath = SceneManagerUtilities.GetCurrentScenePath();
                    var validActions = GetValidActions(assetPath, instance);

                    if (validActions.showDiff)      menu.AddItem(new GUIContent(Terminology.diff),              false, () => VCUtility.DiffWithBase(assetPath));
                    if (validActions.showAdd)       menu.AddItem(new GUIContent(Terminology.add),               false, () => VCCommands.Instance.Add(new[] { assetPath }));
                    if (validActions.showOpen)      menu.AddItem(new GUIContent(Terminology.getlock),           false, () => GetLock(assetPath, instance));
                    if (validActions.showOpenLocal) menu.AddItem(new GUIContent(Terminology.allowLocalEdit),    false, () => AllowLocalEdit(assetPath, instance));
                    if (validActions.showForceOpen) menu.AddItem(new GUIContent("Force " + Terminology.getlock),false, () => GetLock(assetPath, instance, OperationMode.Force));
                    if (validActions.showCommit)    menu.AddItem(new GUIContent(Terminology.commit),            false, () => Commit(assetPath, instance));
                    if (validActions.showUnlock)    menu.AddItem(new GUIContent(Terminology.unlock),            false, () => VCCommands.Instance.ReleaseLock(new[] { assetPath }));
                    if (validActions.showDisconnect)menu.AddItem(new GUIContent("Disconnect"),                  false, () => PrefabHelper.DisconnectPrefab(instance as GameObject));
                    if (validActions.showDelete)    menu.AddItem(new GUIContent(Terminology.delete),            false, () => VCCommands.Instance.Delete(new[] { assetPath }));
                    if (validActions.showRevert)    menu.AddItem(new GUIContent(Terminology.revert),            false, () => Revert(assetPath, instance));
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("..Busy.."));
                }
            }
        }
开发者ID:kjems,项目名称:uversioncontrol,代码行数:28,代码来源:VCGUIControls.cs

示例4: OnContextClick

 public void OnContextClick(int itemIndex)
 {
   GenericMenu genericMenu = new GenericMenu();
   genericMenu.AddItem(new GUIContent("Unexpose"), false, (GenericMenu.MenuFunction2) (data => this.Delete((int) data)), (object) itemIndex);
   genericMenu.AddItem(new GUIContent("Rename"), false, (GenericMenu.MenuFunction2) (data => this.m_ReorderableListWithRenameAndScrollView.BeginRename((int) data, 0.0f)), (object) itemIndex);
   genericMenu.ShowAsContext();
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:7,代码来源:AudioMixerExposedParameterView.cs

示例5: AddItemsToMenu

 public void AddItemsToMenu(GenericMenu menu)
 {
     if (Application.platform == RuntimePlatform.OSXEditor)
     {
         menu.AddItem(new GUIContent("Open Player Log"), false, new GenericMenu.MenuFunction(InternalEditorUtility.OpenPlayerConsole));
     }
     menu.AddItem(new GUIContent("Open Editor Log"), false, new GenericMenu.MenuFunction(InternalEditorUtility.OpenEditorConsole));
     IEnumerator enumerator = Enum.GetValues(typeof(StackTraceLogType)).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             StackTraceLogType current = (StackTraceLogType) ((int) enumerator.Current);
             menu.AddItem(new GUIContent("Stack Trace Logging/" + current), Application.stackTraceLogType == current, new GenericMenu.MenuFunction2(this.ToggleLogStackTraces), current);
         }
     }
     finally
     {
         IDisposable disposable = enumerator as IDisposable;
         if (disposable == null)
         {
         }
         disposable.Dispose();
     }
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:25,代码来源:ConsoleWindow.cs

示例6: SystemEditor

	// ================================================================================================================

	public SystemEditor()
	{
		addSceneMenu = new GenericMenu(); 
		addSceneMenu.AddItem(new GUIContent("Browse"), false, OnAddScene, 0);
		addSceneMenu.AddItem(new GUIContent("New Scene"), false, OnAddScene, 1);
		for (int i = 0; i < inputSettingsFoldout.Length; i++) inputSettingsFoldout[i] = true;
	}
开发者ID:voidserpent,项目名称:rpgbase,代码行数:9,代码来源:SystemEditor.cs

示例7: Show

			public static void Show(int itemIndex, FlexibleMenu caller)
			{
				FlexibleMenu.ItemContextMenu.s_Caller = caller;
				GenericMenu genericMenu = new GenericMenu();
				genericMenu.AddItem(new GUIContent("Edit..."), false, new GenericMenu.MenuFunction2(FlexibleMenu.ItemContextMenu.Edit), itemIndex);
				genericMenu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction2(FlexibleMenu.ItemContextMenu.Delete), itemIndex);
				genericMenu.ShowAsContext();
				GUIUtility.ExitGUI();
			}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:9,代码来源:FlexibleMenu.cs

示例8: OnRightClick

        protected override void OnRightClick(Vector2 mousePosition)
        {
            base.OnRightClick(mousePosition);

            GenericMenu menu = new GenericMenu();
            menu.AddItem(new GUIContent("Add State Transition"), false, AddEdge);
            menu.AddItem(new GUIContent("Delete State"), false, Delete);
            menu.ShowAsContext();
        }
开发者ID:Filoppi,项目名称:Unity-Node-Editor,代码行数:9,代码来源:AIEditorNode.cs

示例9: AddItemsToMenu

 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     if (RenderDoc.IsInstalled() && !RenderDoc.IsLoaded())
     {
         menu.AddItem(Styles.loadRenderDocContent, false, new GenericMenu.MenuFunction(this.LoadRenderDoc));
     }
     menu.AddItem(Styles.noCameraWarningContextMenuContent, this.m_NoCameraWarning, new GenericMenu.MenuFunction(this.ToggleNoCameraWarning));
     menu.AddItem(Styles.clearEveryFrameContextMenuContent, this.m_ClearInEditMode, new GenericMenu.MenuFunction(this.ToggleClearInEditMode));
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:9,代码来源:GameView.cs

示例10: ShowButton

        void ShowButton(Rect position)
        {
            Event e = Event.current;
            if (GUI.Button(position, EditorPlus.EditorPlusIcon, new GUIStyle(GUI.skin.label)))
            {
                if (e.button != 0)
                    return;
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Text Limit/Short Text"), (textLimit == 3), SetTextLimit, 3);
                menu.AddItem(new GUIContent("Text Limit/Full Text"), (textLimit == int.MaxValue), SetTextLimit, int.MaxValue);
                menu.AddItem(new GUIContent("Text Limit/No Text"), (textLimit == 0), SetTextLimit, 0);

                //menu.AddSeparator("Scale");
                menu.AddItem(new GUIContent("Scale/0.5"), (widgetHost.WidgetScale == 0.5f), ChangeScale, 0.5f);
                menu.AddItem(new GUIContent("Scale/0.75"), (widgetHost.WidgetScale == 0.75f), ChangeScale, 0.75f);
                menu.AddItem(new GUIContent("Scale/1.0"), (widgetHost.WidgetScale == 1f), ChangeScale, 1f);
                menu.AddItem(new GUIContent("Scale/1.25"), (widgetHost.WidgetScale == 1.25f), ChangeScale, 1.25f);
                menu.AddItem(new GUIContent("Scale/1.5"), (widgetHost.WidgetScale == 1.5f), ChangeScale, 1.5f);
                menu.AddItem(new GUIContent("Scale/2"), (widgetHost.WidgetScale == 2f), ChangeScale, 2f);
                menu.AddItem(new GUIContent("Scale/3"), (widgetHost.WidgetScale == 3f), ChangeScale, 3f);

                menu.AddItem(new GUIContent("Tooltip/Show"), useTooltip, SetTooltipMode, true);
                menu.AddItem(new GUIContent("Tooltip/Hide"), !useTooltip, SetTooltipMode, false);

                menu.AddSeparator("");
                if (savedHotbars.Count == 0)
                {
                    menu.AddDisabledItem(new GUIContent("Saving/Load"));
                }
                else
                {
                    foreach (string bar in savedHotbars)
                    {
                        menu.AddItem(new GUIContent("Saving/Load/" + bar), false, LoadHotbar, bar);
                    }
                }

                menu.AddItem(new GUIContent("Saving/Save"), false, SaveHotbar);

                menu.AddItem(new GUIContent("Saving/Autosave/On"), useAutoSave, SetAutoSave, true);

                menu.AddItem(new GUIContent("Saving/Autosave/Off"), !useAutoSave, SetAutoSave, false);

                menu.AddItem(new GUIContent("Saving/Clear Saves"), false, ClearAllSaves);

                menu.AddSeparator("");

                menu.AddItem(new GUIContent("Rename"), false, EditorPlusTitleWindow.Init, this);

                menu.AddItem(new GUIContent("Clear Bar"), false, ClearHotbar);


                menu.ShowAsContext();
            }
        }
开发者ID:PramgaOnce,项目名称:GlobalGameJam2016,代码行数:56,代码来源:EditorPlusHotbar.cs

示例11: AddItemsToMenu

 public void AddItemsToMenu(GenericMenu menu)
 {
     menu.AddItem(m_GUIRunOnRecompile, m_Settings.runOnRecompilation, ToggleRunOnRecompilation);
     menu.AddItem(m_GUIRunTestsOnNewScene, m_Settings.runTestOnANewScene, m_Settings.ToggleRunTestOnANewScene);
     if(!m_Settings.runTestOnANewScene)
         menu.AddDisabledItem(m_GUIAutoSaveSceneBeforeRun);
     else
         menu.AddItem(m_GUIAutoSaveSceneBeforeRun, m_Settings.autoSaveSceneBeforeRun, m_Settings.ToggleAutoSaveSceneBeforeRun);
     menu.AddItem(m_GUIShowDetailsBelowTests, m_Settings.horizontalSplit, m_Settings.ToggleHorizontalSplit);
 }
开发者ID:claytantor,项目名称:shadow-haven-unity,代码行数:10,代码来源:UnitTestView.cs

示例12: OnGUI

        /// <summary> 
        /// Draws the gui control.
        /// <param name="position">Rectangle on the screen to use for the property GUI.</param>
        /// <param name="property">The SerializedProperty to make the custom GUI for.</param>
        /// <param name="label">The label of this property.</param>
        /// </summary>
        public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {
            // Get state
            var targetState = property.serializedObject.targetObject as InternalStateBehaviour;

            // It's a valid state?
            if (targetState != null) {
                // Draw prefix label
                #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                Rect controlPosition = EditorGUI.PrefixLabel(position, EditorGUIUtility.GetControlID(FocusType.Passive, position), label);
                #else
                Rect controlPosition = EditorGUI.PrefixLabel(position, label);
                #endif

                // Get the parent
                ParentBehaviour parent = targetState.parent;

                // Draw button as popup
                if (GUI.Button(controlPosition, parent != null ? parent.stateName : "Null", EditorStyles.popup)) {
                    
                    // Get valid parents for the state
                    List<ParentBehaviour> validParents = new List<ParentBehaviour>();
                    var targetParent = targetState as ParentBehaviour;
                    validParents.AddRange(targetState.GetComponents<ParentBehaviour>());

                    // The target state is a parent behaviour?
                    if (targetParent != null) {
                        for (int i = validParents.Count - 1; i >= 0; i--) {
                            // it's the targetParent?
                            if (validParents[i] == targetParent)
                                validParents.RemoveAt(i);
                            // The parent is a child of the target parent?
                            else if (validParents[i].IsAncestor(targetParent))
                                validParents.RemoveAt(i);
                        }
                    }

                    // Create menu
                    var menu = new GenericMenu();

                    // Add null item
                    menu.AddItem(new GUIContent("Null"), parent == null, this.OnSetNewParent, new SetParent(targetState, null));

                    // Add menu items
                    var parentNames = new List<string>();
                    for (int i = 0; i < validParents.Count; i++) {
                        string parentName = StringHelper.GetUniqueNameInList(parentNames, validParents[i].fullStateName);
                        parentNames.Add(parentName);
                        menu.AddItem(new GUIContent(parentName), parent == validParents[i], this.OnSetNewParent, new SetParent(targetState, validParents[i]));
                    }

                    // Show context menu
                    menu.ShowAsContext();
                }
            }
        }
开发者ID:xclouder,项目名称:godbattle,代码行数:61,代码来源:ParentPropertyDrawer.cs

示例13: DrawLocationMenu

 private void DrawLocationMenu()
 {
     if (GUILayout.Button("Menu", "MiniPullDown", GUILayout.Width(56))) {
         GenericMenu menu = new GenericMenu();
         menu.AddItem(new GUIContent("New Location"), false, AddNewLocation);
         menu.AddItem(new GUIContent("Sort/By Name"), false, SortLocationsByName);
         menu.AddItem(new GUIContent("Sort/By ID"), false, SortLocationsByID);
         menu.AddItem(new GUIContent("Sync From DB"), database.syncInfo.syncLocations, ToggleSyncLocationsFromDB);
         menu.ShowAsContext();
     }
 }
开发者ID:farreltr,项目名称:OneLastSunset,代码行数:11,代码来源:DialogueEditorWindowLocationSection.cs

示例14: DrawTemplateMenu

 private void DrawTemplateMenu()
 {
     if (GUILayout.Button("Menu", "MiniPullDown", GUILayout.Width(56))) {
         GenericMenu menu = new GenericMenu();
         menu.AddItem(new GUIContent("Export XML..."), false, ExportTemplate);
         menu.AddItem(new GUIContent("Import XML..."), false, ImportTemplate);
         menu.AddItem(new GUIContent("Update From Assets"), false, ConfirmUpdateFromAssets);
         menu.AddItem(new GUIContent("Reset"), false, ResetTemplate);
         menu.ShowAsContext();
     }
 }
开发者ID:farreltr,项目名称:OneLastSunset,代码行数:11,代码来源:DialogueEditorWindowTemplateSection.cs

示例15: Show

 internal static void Show(SerializedProperty prop)
 {
   GUIContent content1 = new GUIContent("Copy");
   GUIContent content2 = new GUIContent("Paste");
   GenericMenu genericMenu = new GenericMenu();
   genericMenu.AddItem(content1, false, new GenericMenu.MenuFunction(new GradientContextMenu(prop).Copy));
   if (ParticleSystemClipboard.HasSingleGradient())
     genericMenu.AddItem(content2, false, new GenericMenu.MenuFunction(new GradientContextMenu(prop).Paste));
   else
     genericMenu.AddDisabledItem(content2);
   genericMenu.ShowAsContext();
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:12,代码来源:GradientContextMenu.cs


注:本文中的UnityEditor.GenericMenu.AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。