Documentation for Unity Asset Store version v1.20
Add Button To Menu
Since version v1.20 the level editor is completely independent of the UI implementation. You do not need to use any rigid UI extension system. Simply add the needed UI to the scene. To extend the menu of the built-in example UI duplicate the 'Back To Editor' button (search for 'BackToEditorBtn'), rearrange it, update its text and add your script callback to its 'OnClick()' function. Remove the '
uMyGUI_PopupText.OnButtonClick' callback from the 'OnClick()' function to keep the menu open when your button is clicked. Keep the '
uMyGUI_PopupText.OnButtonClick' callback to let the menu close after click. If you want to use a custom UI, then you can find more information in
this article.
Documentation for Unity Asset Store versions v1.01 and v1.10
Summary
The left menu will be enabled as soon as it has at least one button. To add a button to the left menu the name of the button must be added to an array in the inspector of a '
LE_GUILevelEditor' instance in the level editor scene. Once this is done the button will be added and events will be fired on click. An event handler needs to be provided for the new button in order to implement its functionality.
Step 1: Add Button Name In Inspector
To add a button to the left menu select the instance of '
LE_GUILevelEditor' in your level editor scene and add the button name to the '
LEFT_MENU_BUTTONS' array in the inspector. In this example we add the 'Exit' button.
Step 2: Event Registration
The code below will add the OnExit event handler method to the methods called when the 'Exit' button is clicked. The string passed in the first parameter has to exactly match the string entered in the inspector. Keep in mind that you also should unregister the event handler when your script gets destroyed otherwise a memory leak could occur.
LE_EventInterface.AddAdditionalLeftMenuButtonHandler("Exit", OnExit);
Step 3: Event Handling
Put the code that you want to execute when the button is clicked in the event handler method. For example the 'Exit' button event handler could quit the application.
private void OnExit(object p_sender, System.EventArgs p_args)
{
Application.Quit();
}