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


C# GenericMenu.ShowAsContext方法代码示例

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


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

示例1: OnAddDropDown

 private void OnAddDropDown(Rect buttonRect, ReorderableList list)
 {
     var menu = new GenericMenu();
     if (kModule._inputData.Length >= 2) return;
     if (kModule._inputData.Length == 0)
     {
         menu.AddItem(new GUIContent("Right Hand"),
                  false, OnClickHandler,
                  new DataParams() { jointType = KinectUIHandType.Right });
         menu.AddItem(new GUIContent("Left Hand"),
                  false, OnClickHandler,
                  new DataParams() { jointType = KinectUIHandType.Left });
     }
     else if (kModule._inputData.Length == 1)
     {
         DataParams param;
         string name;
         if (kModule._inputData[0].trackingHandType == KinectUIHandType.Left){
             param = new DataParams() { jointType = KinectUIHandType.Right };
             name = "Right Hand";
         }
         else
         {
             param = new DataParams() { jointType = KinectUIHandType.Left };
             name = "Left Hand";
         }
         menu.AddItem(new GUIContent(name),false, OnClickHandler, param);
     }
     menu.ShowAsContext();
 }
开发者ID:ly774508966,项目名称:Kinect-Inputmodule,代码行数:30,代码来源:KinectInputModuleEditor.cs

示例2: addTrackContext

    /// <summary>
    /// Create and show a context menu for adding new Timeline Tracks.
    /// </summary>
    protected override void addTrackContext()
    {
        TrackGroup trackGroup = TrackGroup.Behaviour as TrackGroup;
        if(trackGroup != null)
        {
            // Get the possible tracks that this group can contain.
            List<Type> trackTypes = trackGroup.GetAllowedTrackTypes();
            
            GenericMenu createMenu = new GenericMenu();

            // Get the attributes of each track.
            foreach (Type t in trackTypes)
            {
                MemberInfo info = t;
                string label = string.Empty;
                foreach (TimelineTrackAttribute attribute in info.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
                {
                    label = attribute.Label;
                    break;
                }

                createMenu.AddItem(new GUIContent(string.Format("Add {0}", label)), false, addTrack, new TrackContextData(label, t, trackGroup));
            }

            createMenu.ShowAsContext();
        }
    }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:30,代码来源:GenericTrackGroupControl.cs

示例3: OnGUI

 public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
 {
     //SerializedProperty me = prop.FindPropertyRelative("this");
     //SerializedProperty scale = prop.FindPropertyRelative("scale");
     //SerializedProperty curve = prop.FindPropertyRelative("curve");
     //EditorGUI.LabelField(pos, "hi" + resources);
     var rowRect = new Rect(pos.x, pos.y, pos.width, base.GetPropertyHeight(prop, label));
     isFoldedOut = EditorGUI.Foldout(new Rect(rowRect.x, rowRect.y, rowRect.width - 20, rowRect.height), isFoldedOut, "Resources");
     if (isFoldedOut) {
         var resources = prop.FindPropertyRelative("Resources");
         if (GUI.Button(new Rect(rowRect.x + rowRect.width - 22, rowRect.y + 1, 22, rowRect.height - 2), "+")) {
             resources.InsertArrayElementAtIndex(resources.arraySize);
         }
         rowRect.y += rowRect.height;
         for (int i = 0; i < resources.arraySize; ++i) {
             var item = resources.GetArrayElementAtIndex(i);
             var minusClick = GUI.Button(new Rect(rowRect.x, rowRect.y, 22, rowRect.height), "-");
             EditorGUI.PropertyField(new Rect(rowRect.x + 20, rowRect.y, rowRect.width - 21, rowRect.height), item);
             if (minusClick) {
                 if (Event.current.button == 1) {
                     // Now create the menu, add items and show it
                     var menu = new GenericMenu();
                     if (i > 0)
                         menu.AddItem(new GUIContent("Move Up"), false, (itm) => { resources.MoveArrayElement((int)itm, (int)itm - 1); }, i);
                     if (i < resources.arraySize - 1)
                         menu.AddItem(new GUIContent("Move Down"), false, (itm) => { resources.MoveArrayElement((int)itm, (int)itm + 1); }, i);
                     menu.ShowAsContext();
                 } else {
                     resources.DeleteArrayElementAtIndex(i--);
                 }
             }
             rowRect.y += rowRect.height;
         }
     }
 }
开发者ID:JordanAupetit,项目名称:ProjectDungeon,代码行数:35,代码来源:ResourceCollectionEditor.cs

示例4: showHeaderContextMenu

    protected override void showHeaderContextMenu()
    {
        GenericMenu createMenu = new GenericMenu();
        createMenu.AddItem(new GUIContent("Select"), false, focusActor);
        createMenu.AddItem(new GUIContent("Delete"), false, delete);

        createMenu.ShowAsContext();
    }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:8,代码来源:ActorTrackGroupControl.cs

示例5: updateHeaderControl3

    private int controlID; // The control ID for this track control.

    /// <summary>
    /// Header Control 3 is typically the "Add" control.
    /// </summary>
    /// <param name="position">The position that this control is drawn at.</param>
    protected override void updateHeaderControl3(UnityEngine.Rect position)
    {
        TimelineTrack track = TargetTrack.Behaviour as TimelineTrack;
        if (track == null) return;

        Color temp = GUI.color;
        GUI.color = (track.GetTimelineItems().Length > 0) ? Color.green : Color.red;

        controlID = GUIUtility.GetControlID(track.GetInstanceID(), FocusType.Passive, position);

        if (GUI.Button(position, string.Empty, TrackGroupControl.styles.addIcon))
        {
            // Get the possible items that this track can contain.
            List<Type> trackTypes = track.GetAllowedCutsceneItems();

            if (trackTypes.Count == 1)
            {
                // Only one option, so just create it.
                ContextData data = getContextData(trackTypes[0]);
                if (data.PairedType == null)
                {
                    addCutsceneItem(data);
                }
                else
                {
                    showObjectPicker(data);
                }
            }
            else if (trackTypes.Count > 1)
            {
                // Present context menu for selection.
                GenericMenu createMenu = new GenericMenu();
                foreach (Type t in trackTypes)
                {
                    ContextData data = getContextData(t);

                    createMenu.AddItem(new GUIContent(string.Format("{0}/{1}", data.Category, data.Label)), false, addCutsceneItem, data);
                }
                createMenu.ShowAsContext();
            }
        }

        // Handle the case where the object picker has a value selected.
        if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "ObjectSelectorClosed")
        {
            if (EditorGUIUtility.GetObjectPickerControlID() == controlID)
            {
                UnityEngine.Object pickedObject = EditorGUIUtility.GetObjectPickerObject();

                if(pickedObject != null)
                    addCutsceneItem(savedData, pickedObject);

                Event.current.Use();
            }
        }

        GUI.color = temp;
    }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:64,代码来源:GenericTrackControl.cs

示例6: OpenContextMenu

	void OpenContextMenu()
	{
		GenericMenu menu = new GenericMenu();

		menu.AddItem (new GUIContent("Open As Floating Window", ""), false, Menu_OpenAsFloatingWindow);
		menu.AddItem (new GUIContent("Open As Dockable Window", ""), false, Menu_OpenAsDockableWindow);

		menu.ShowAsContext ();
	}		
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:9,代码来源:pb_Vertex_Color_Toolbar.cs

示例7: ClearConnectionMenu

    public void ClearConnectionMenu()
    {
        GenericMenu menu = new GenericMenu ();

        menu.AddSeparator ("ARE YOU SURE YOU WANT TO CLEAR?");
        menu.AddSeparator ("");
        menu.AddItem(new GUIContent ("Clear"), false, ClearConnections, "");
        menu.AddItem(new GUIContent ("Don't Clear"), false, DontClearConnections, "");

        menu.ShowAsContext ();
    }
开发者ID:ekhudson,项目名称:Train2013,代码行数:11,代码来源:ConnectionRegistryEditor.cs

示例8: DrawAddTabGUI

    public static void DrawAddTabGUI(List<AlloyTabAdd> tabsToAdd) {
        if (tabsToAdd.Count <= 0) {
            return;
        }
        
        
        GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);
        GUILayout.Label("");
        var rect = GUILayoutUtility.GetLastRect();

        rect.x -= 35.0f;
        rect.width += 10.0f;

        GUI.color = Color.clear;
        bool add = GUI.Button(rect, new GUIContent(""), "Box");
        GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);
        Rect subRect = rect;

        foreach (var tab in tabsToAdd) {
            GUI.color = tab.Color;
            GUI.Box(subRect, "", "ShurikenModuleTitle");

            subRect.x += rect.width / tabsToAdd.Count;
            subRect.width -= rect.width / tabsToAdd.Count;
        }

        GUI.color = new Color(0.8f, 0.8f, 0.8f, 0.8f);

        var delRect = rect;
        delRect.xMin = rect.xMax;
        delRect.xMax += 40.0f;

        if (GUI.Button(delRect, "", "ShurikenModuleTitle") || add) {
            var menu = new GenericMenu();

            foreach (var tab in tabsToAdd) {
                menu.AddItem(new GUIContent(tab.Name), false, tab.Enable);
            }

            menu.ShowAsContext();
        }

        delRect.x += 10.0f;

        GUI.Label(delRect, "+");
        rect.x += EditorGUIUtility.currentViewWidth / 2.0f - 30.0f;

        // Ensures tab text is always white, even when using light skin in pro.
        GUI.color = EditorGUIUtility.isProSkin ? new Color(0.7f, 0.7f, 0.7f) : new Color(0.9f, 0.9f, 0.9f);
        GUI.Label(rect, "Add tab", EditorStyles.whiteLabel);
        GUI.color = Color.white;
    }
开发者ID:jharger,项目名称:globalgamejam2016,代码行数:52,代码来源:AlloyEditor.cs

示例9: OnEnable

	private void OnEnable() {
		list = new ReorderableList(serializedObject, 
		                           serializedObject.FindProperty("Waves"), 
		                           true, true, true, true);
		list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
			var element = list.serializedProperty.GetArrayElementAtIndex(index);
			rect.y += 2;
			EditorGUI.PropertyField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Type"), GUIContent.none);
			EditorGUI.PropertyField(new Rect(rect.x + 60, rect.y, rect.width - 60 - 30, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Prefab"), GUIContent.none);
			EditorGUI.PropertyField(new Rect(rect.x + rect.width - 30, rect.y, 30, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Count"), GUIContent.none);
		};
		list.drawHeaderCallback = (Rect rect) => {
			EditorGUI.LabelField(rect, "Monster Waves");
		};
		list.onSelectCallback = (ReorderableList l) => {
			var prefab = l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("Prefab").objectReferenceValue as GameObject;
			if (prefab) EditorGUIUtility.PingObject(prefab.gameObject);
		};
		list.onCanRemoveCallback = (ReorderableList l) => {
			return l.count > 1;
		};
		list.onRemoveCallback = (ReorderableList l) => {
			if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete the wave?", "Yes", "No"))
			{
				ReorderableList.defaultBehaviours.DoRemoveButton(l);
			}
		};
		list.onAddCallback = (ReorderableList l) => {
			var index = l.serializedProperty.arraySize;
			l.serializedProperty.arraySize++;
			l.index = index;
			var element = l.serializedProperty.GetArrayElementAtIndex(index);
			element.FindPropertyRelative("Type").enumValueIndex = 0;
			element.FindPropertyRelative("Count").intValue = 20;
			element.FindPropertyRelative("Prefab").objectReferenceValue = AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Mobs/Cube.prefab", typeof(GameObject)) as GameObject;
		};
		list.onAddDropdownCallback = (Rect buttonRect, ReorderableList l) => {
			var menu = new GenericMenu();
			var guids = AssetDatabase.FindAssets("", new[]{"Assets/Prefabs/Mobs"});
			foreach (var guid in guids) {
				var path = AssetDatabase.GUIDToAssetPath(guid);
				menu.AddItem(new GUIContent("Mobs/" + Path.GetFileNameWithoutExtension(path)), false, clickHandler, new WaveCreationParams() {Type = MobWave.WaveType.Mobs, Path = path});
			}
			guids = AssetDatabase.FindAssets("", new[]{"Assets/Prefabs/Bosses"});
			foreach (var guid in guids) {
				var path = AssetDatabase.GUIDToAssetPath(guid);
				menu.AddItem(new GUIContent("Bosses/" + Path.GetFileNameWithoutExtension(path)), false, clickHandler, new WaveCreationParams() {Type = MobWave.WaveType.Boss, Path = path});
			}
			menu.ShowAsContext();
		};
	}
开发者ID:T4U3D,项目名称:ReorderableListExample,代码行数:51,代码来源:LevelDataEditor.cs

示例10: OnGUI

 void OnGUI()
 {
     windowRect = new Rect(0, 0, Screen.width, Screen.height);
     if(Event.current.type == EventType.ContextClick)
     {
         Vector2 mousePos = Event.current.mousePosition;
         if(windowRect.Contains(mousePos))
         {
             GenericMenu menu = new GenericMenu();
             menu.AddItem(new GUIContent("CreateCube"), false, createMenu, "createCube");
             menu.ShowAsContext();
         }
     }
 }
开发者ID:ryonandesukedo,项目名称:Unity-Editor,代码行数:14,代码来源:createCube.cs

示例11: CreateNodeMenu

    public static void CreateNodeMenu(Vector2 position, GenericMenu.MenuFunction2 MenuCallback)
    {
        GenericMenu menu = new GenericMenu();

        var assembly = Assembly.Load(new AssemblyName("Assembly-CSharp"));
        var paramTypes = (from t in assembly.GetTypes() where t.IsSubclassOfRawGeneric(typeof(AParameterNode<>)) && !t.IsAbstract select t).ToArray();
        var flowTypes = (from t in assembly.GetTypes() where t.IsSubclassOfRawGeneric(typeof(AFlowNode)) && !t.IsAbstract select t).ToArray();
        foreach(System.Type t in paramTypes) {
            menu.AddItem(new GUIContent(string.Format("Parameter Nodes/{0}", t.Name)), false, MenuCallback, new NodeCallbackData(position, t));
        }
        foreach(System.Type t in flowTypes) {
            menu.AddItem(new GUIContent(string.Format("Flow Nodes/{0}", t.Name)), false, MenuCallback, new NodeCallbackData(position, t));
        }
        menu.AddItem(new GUIContent("TaskNode"), false, MenuCallback, new NodeCallbackData(position, typeof(TaskNode)));
        menu.AddItem(new GUIContent("TreeNode"), false, MenuCallback, new NodeCallbackData(position, typeof(TreeNode)));
        menu.ShowAsContext();
    }
开发者ID:marekdaniluk,项目名称:lab,代码行数:17,代码来源:NodeFactory.cs

示例12: showBodyContextMenu

    protected override void showBodyContextMenu(Event evt)
    {
        MultiCurveTrack itemTrack = TargetTrack.Behaviour as MultiCurveTrack;
        if (itemTrack == null) return;

        Behaviour b = DirectorCopyPaste.Peek();

        PasteContext pasteContext = new PasteContext(evt.mousePosition, itemTrack);
        GenericMenu createMenu = new GenericMenu();
        if (b != null && DirectorHelper.IsTrackItemValidForTrack(b, itemTrack))
        {
            createMenu.AddItem(new GUIContent("Paste"), false, pasteItem, pasteContext);
        }
        else
        {
            createMenu.AddDisabledItem(new GUIContent("Paste"));
        }
        createMenu.ShowAsContext();
    }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:19,代码来源:MultiActorCurveTrackControl.cs

示例13: showContextMenu

    protected override void showContextMenu(Behaviour behaviour)
    {
        CinemaActorClipCurve clipCurve = behaviour as CinemaActorClipCurve;
        if (clipCurve == null) return;

        List<KeyValuePair<string, string>> currentCurves = new List<KeyValuePair<string, string>>();
        foreach (MemberClipCurveData data in clipCurve.CurveData)
        {
            KeyValuePair<string, string> curveStrings = new KeyValuePair<string, string>(data.Type, data.PropertyName);
            currentCurves.Add(curveStrings);
        }

        GenericMenu createMenu = new GenericMenu();

        if (clipCurve.Actor != null)
        {
            Component[] components = DirectorHelper.getValidComponents(clipCurve.Actor.gameObject);

            for (int i = 0; i < components.Length; i++)
            {
                Component component = components[i];
                MemberInfo[] members = DirectorHelper.getValidMembers(component);
                for (int j = 0; j < members.Length; j++)
                {
                    AddCurveContext context = new AddCurveContext();
                    context.clipCurve = clipCurve;
                    context.component = component;
                    context.memberInfo = members[j];
                    if (!currentCurves.Contains(new KeyValuePair<string, string>(component.GetType().Name, members[j].Name)))
                    {
                        createMenu.AddItem(new GUIContent(string.Format("Add Curve/{0}/{1}", component.GetType().Name, DirectorHelper.GetUserFriendlyName(component, members[j]))), false, addCurve, context);
                    }
                }
            }
            createMenu.AddSeparator(string.Empty);
        }
        createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour);
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, clipCurve);
        createMenu.ShowAsContext();
    }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:41,代码来源:CinemaActorCurveControl.cs

示例14: showContextMenu

    protected override void showContextMenu(Behaviour behaviour)
    {
        CinemaShot shot = behaviour as CinemaShot;
        if (shot == null) return;

        Camera[] cameras = GameObject.FindObjectsOfType<Camera>();
        
        GenericMenu createMenu = new GenericMenu();
        createMenu.AddItem(new GUIContent("Focus"), false, focusShot, shot);
        foreach (Camera c in cameras)
        {
            
            ContextSetCamera arg = new ContextSetCamera();
            arg.shot = shot;
            arg.camera = c;
            createMenu.AddItem(new GUIContent(string.Format(MODIFY_CAMERA, c.gameObject.name)), false, setCamera, arg);
        }
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour);
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, shot);
        createMenu.ShowAsContext();
    }
开发者ID:ArthurRasmusson,项目名称:UofTHacks2016,代码行数:23,代码来源:CinemaShotControl.cs

示例15: OnInspectorGUI

    public override void OnInspectorGUI()
    {
        DrawToolbarGUI();

        bool dirty = DrawGeneralGUI();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        showMarkers = Foldout(showMarkers, "2D Markers");
        if (showMarkers) DrawMarkersGUI();
        EditorGUILayout.EndVertical();

        if (api.target == OnlineMapsTarget.texture)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            showCreateTexture = Foldout(showCreateTexture, "Create texture");
            if (showCreateTexture) DrawCreateTextureGUI(ref dirty);
            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.BeginVertical(GUI.skin.box);
        showAdvanced = Foldout(showAdvanced, "Advanced");
        if (showAdvanced) DrawAdvancedGUI(ref dirty);
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        showTroubleshooting = Foldout(showTroubleshooting, "Troubleshooting");
        if (showTroubleshooting) DrawTroubleshootingGUI(ref dirty);
        EditorGUILayout.EndVertical();

        OnlineMapsControlBase[] controls = api.GetComponents<OnlineMapsControlBase>();
        if (controls == null || controls.Length == 0)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.HelpBox("Problem detected:\nCan not find OnlineMaps Control component.", MessageType.Error);
            if (GUILayout.Button("Add Control"))
            {
                GenericMenu menu = new GenericMenu();

                Type[] types = api.GetType().Assembly.GetTypes();
                foreach (Type t in types)
                {
                    if (t.IsSubclassOf(typeof(OnlineMapsControlBase)))
                    {
                        if (t == typeof(OnlineMapsControlBase2D) || t == typeof(OnlineMapsControlBase3D)) continue;

                        string fullName = t.FullName.Substring(10);

                        int controlIndex = fullName.IndexOf("Control");
                        fullName = fullName.Insert(controlIndex, " ");

                        int textureIndex = fullName.IndexOf("Texture");
                        if (textureIndex > 0) fullName = fullName.Insert(textureIndex, " ");

                        menu.AddItem(new GUIContent(fullName), false, data =>
                        {
                            Type ct = data as Type;
                            api.gameObject.AddComponent(ct);
                            api.target = (ct == typeof (OnlineMapsTileSetControl))
                                ? OnlineMapsTarget.tileset
                                : OnlineMapsTarget.texture;
                            Repaint();
                        }, t);
                    }
                }

                menu.ShowAsContext();
            }

            EditorGUILayout.EndVertical();
        }

        if (dirty)
        {
            EditorUtility.SetDirty(api);
            Repaint();
        }
    }
开发者ID:Ronnie619,项目名称:TouchScreenKiosk,代码行数:78,代码来源:OnlineMapsEditor.cs


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