Skip to content

Garume/ContextCircleMenu

Repository files navigation

Context Circle Menu

Context Circle Menu is Unity tool that allows users to open a circular menu in the Scene view to quickly execute user-defined methods, enhancing workflow efficiency.

license Unity 2022.3+

日本語版

Overview

Context Circle Menu is a simple open-source tool for Unity. It lets users open a circular menu in the Scene view or as a standalone VisualElement. This menu makes it easy to quickly use your own methods, helping you work faster by avoiding complex menus. Perfect for developers wanting to manage their scenes better and save time, Context Circle Menu is flexible and easy to use.

Image from Gyazo

Image from Gyazo

Feature

  • Create Context Circle Menu

alt text

  • Easy to use Editor Icon

  • Customized Menu

    • Add from Attribute

    alt text

    • Add Manual

    alt text

  • Open in Scene View

  • Customized Shortcut Key

alt text

Table of Contents

Setup

Requirements

  • Unity 2022.3 or higher

Installation

  1. select Window > Package Manager
  2. Select the "+" button > Add package from git URL
  3. Enter the following URL
https://github.com/Garume/ContextCircleMenu.git?path=/Assets/ContextCircleMenu

Or open Packages/manifest.json and add the following to the dependencies block

{
    "dependencies": {
        "com.garume.context-circle-menu": "https://github.com/Garume/ContextCircleMenu.git?path=/Assets/ContextCircleMenu"
    }
}

Demonstration

Just apply the Context Circle Menu attribute to the static method you wish to add.

public class Menu
{
    [ContextCircleMenu("Debug Test")]
    public static void TestMethod()
    {
        Debug.Log("TestMethod");
    }
}

Then you will see below menu.

Press the A key on the scene view.

Image from Gyazo

If you want to create folders, separate them with /.

public class Menu
{
    [ContextCircleMenu("Example/Debug Test")]
    public static void TestMethod()
    {
        Debug.Log("TestMethod");
    }
}

Then you will see below menu.

Image from Gyazo

Editor Icons

Icons can be attached to menu buttons.

The EditorIcons class is provided as a utility to add icon easily.

To add an icon, do the below.

[ContextCircleMenu("Debug Test", EditorIcons.ConsoleInfoIcon)]
public static void TestMethod()
{
    Debug.Log("TestMethod");
}

Customized Menu

Manual Add Method

If you do not want to use the Context Circle Menu attribute, you can register the method manually.

The process of registering methods internally can be hooked.

public class Menu
{
    [InitializeOnLoadMethod]
    private static void Initialize()
    {
        ContextCircleMenuLoader.OnBuild += (builder =>
        {
            builder.AddMenu("Debug Test", EditorGUIUtility.IconContent(EditorIcons.ConsoleInfoIcon), () => Debug.Log("Debug Test"));
            builder.AddMenu("Instantiate/Cube", EditorGUIUtility.IconContent(EditorIcons.PreMatCube), ()=> GameObject.CreatePrimitive(PrimitiveType.Cube));
            builder.AddMenu("Instantiate/Sphere", EditorGUIUtility.IconContent(EditorIcons.PreMatSphere), ()=> GameObject.CreatePrimitive(PrimitiveType.Sphere));
        });
    }
}

Customized Button

If you don't like the button UI, you can replace it with your own.

Use builder.ConfigureFolder();

Caution

It is an incomplete feature.

Destructive changes may be made.

First, you need to create a FolderMenu that extends CircleMenu. You can create buttons freely in CreateButtons. Please refer to FolderCircleMenu.cs for detailed code.

Next, create a FolderMenuFactory that implements IFolderCircleMenuFactory. Please refer to CircleMenuFactory for detailed code.

Finally, you can replace the UI by doing the below.

ContextCircleMenuLoader.OnBuild += (builder =>
{
    ...
    builder.ConfigureFolder(FolderMenuFactory);
});

Customized Shortcut Key

The default menu open/close button is set to the A key, but can be changed freely.

Edit > Shortcuts to open a window.

Search for Context Circle Menu and you will find the settings as shown in the figure below.

alt text

Set the keys as you like.

LISENCE

MIT

AUTHOR

@Garume

About

Open a circule menu in your Scene view to quickly execute user-defined methods, enhancing workflow efficiency.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages