Getting Started

Let's take a look at the Ultimate Radial Menu and see how to get it working in your project as quick as possible!

Please take just a moment to view the introduction video for the Ultimate Radial Menu if you have not done so already. This video will explain how to get started using the Ultimate Radial Menu and help you understand how to implement it into your project.

The Ultimate Radial Menu has been built from the ground up with being easy to use and customize to make it work the way that you want. However, that being said, the Ultimate Radial Menu asset can be a bit tricky to understand how to use at first.

To begin we'll look at how to simply create an Ultimate Radial Menu in your scene. After that we will go over how to reference the Ultimate Radial Menu in your custom scripts. Let's begin!

How to Create

To create an Ultimate Radial Menu in your scene, simply find the Ultimate Radial Menu prefab that you would like to add and drag the prefab into the scene. The Ultimate Radial Menu prefab will automatically find or create a canvas in your scene for you.

Prefabs can be found at: Assets/Tank & Healer Studio/Ultimate Radial Menu/Prefabs

How to Reference

To understand how to use the Ultimate Radial Menu into your scripts, first let us talk about how it actually works to see how we can best implement the radial menu. We will be going over the Callback System that the radial menu uses as well as a certain class that you will be using to send information to the radial button. Below are the topics mentioned.

Callback System

The Callback System simply sends information to your scripts about which button has been interacted with. When you get to implementing the code, you will see a parameter named: ButtonCallback. This is where you will pass your function that you want the button to call when being interacted with.

For example, let's say you want to use the radial menu as a pause menu. Likely, in your pause menu script, you have a function named: PauseGame(), or something similar. When subscribing to the pause button on your radial menu, you will want to pass your PauseGame function as the ButtonCallback parameter. Then, when the user clicks on the pause button the Ultimate Radial Menu will call your PauseGame function and pause your game.

UltimateRadialButtonInfo Class

The UltimateRadialButtonInfo class is public and will be used inside of your own custom scripts. It is used just like any other variable inside of your own scripts, but has a custom property drawer so that the information is a little easier to work with.

This class is what you will send to the Ultimate Radial Menu to update the information like: Name, Description, Key, ID, Icon, and so forth. After sending in your UltimateRadialButtonInfo to the radial menu, it will then have access to a few functions that you can use to keep information updated, without referencing back to the Ultimate Radial Menu.

For instance, let's continue on the example above with using the radial menu as a pause menu. In your variables, you will want to have a public UltimateRadialButtonInfo variable.

void Start ()
{
    // Call the RegisterButton function on the PauseMenu radial menu, and pass in the PauseGame function as the ButtonCallback and then the pauseButtonInfo as the new button information to the first index of the pause menu buttons.
    UltimateRadialMenu.RegisterButton( "PauseMenu", PauseGame, pauseButtonInfo );
}

After this code, the radial menu's first available button will be your pause button and will call the PauseGame function when being interacted with.

We are not done though! The UltimateRadialButtonInfo class has so much more functionality than first meets the eye. After passing in the pauseButtonInfo to the radial menu, it has actually been authorized control over the radial button that it has been assigned to, giving you access to more useful functions to keep the button updated.

Let's discuss one more example of how to update the radial button using this class. In the same scenario, inside your PauseGame() function, now you can update the icon of the button by simply using the pauseButtonInfo class. Let's see how:

void PauseGame ()
{
    // Here is where your custom logic would be to pause the game, but this is just a simple way to pause your game.

    // If the timescale is 1, then the game is playing right now...
    if( Time.timeScale == 1.0f )
    {
        // So set the timescale to 0 to pause the game.
        Time.timeScale = 0.0f;

        // Since the game is now paused, update the icon to being a play button, instead of pause.
        pauseButtonInfo.UpdateIcon( playButtonIcon );

        // Update the text of the button to say "Play" now instead of pause.
        pauseButtonInfo.UpdateText( "Play" );
    }
    // Else the timescale is not 1, and therefore is paused...
    else
    {
        // So set the timescale to 1 to play the game again.
        Time.timeScale = 1.0f;

        // Since the game is playing again, update the icon back to being a pause button.
        pauseButtonInfo.UpdateIcon( pauseButtonIcon );

        // Update the text to now say "Pause" instead of play.
        pauseButtonInfo.UpdateText( "Pause" );
    }
}

As you can see, the pauseButtonInfo can now be used to update information about the button that it has been assigned.

For a full list of the functions available, please see the Documention section.

Last updated