Exemple #1
0
        void OnValueChanged(ChangeEvent <bool> evt)
        {
            var isGOToolContext = ToolManager.activeContextType == typeof(GameObjectToolContext);

            if (evt.newValue && isGOToolContext)
            {
                ToolManager.CycleToolContexts();
            }
            else if (!evt.newValue && !isGOToolContext)
            {
                ToolManager.ExitToolContext();
            }
        }
Exemple #2
0
        void ShowContextMenu()
        {
            var menu = new GenericMenu();

            foreach (var ctx in EditorToolUtility.availableGlobalToolContexts)
            {
                if (ctx.editor != typeof(GameObjectToolContext))
                {
                    menu.AddItem(
                        new GUIContent(EditorToolUtility.GetToolName(ctx.editor)),
                        ToolManager.activeContextType == ctx.editor,
                        () =>
                    {
                        if (ToolManager.activeContextType == ctx.editor)
                        {
                            ToolManager.ExitToolContext();
                        }
                        else
                        {
                            ToolManager.SetActiveContext(ctx.editor);
                        }
                    });
                }
            }

            foreach (var ctx in EditorToolManager.componentContexts)
            {
                menu.AddItem(
                    new GUIContent(EditorToolUtility.GetToolName(ctx.editorType)),
                    EditorToolManager.activeToolContext == ctx.editor,
                    () =>
                {
                    if (EditorToolManager.activeToolContext == ctx.editor)
                    {
                        ToolManager.ExitToolContext();
                    }
                    else
                    {
                        ToolManager.SetActiveContext(ctx.editorType);
                    }
                });
            }

            menu.DropDown(worldBound);
        }