Documentation for Unity Asset Store version v1.20
Add Button To Level Tab
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 level tab of the built-in example UI duplicate the 'Load' button (search for 'RightMenu_Level_LoadBtn'), rearrange it, update its text and change its 'OnClick()' function to call your script. 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
To add an additional button to the level tab of the editor 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 level tab of the right menu window select the instance of '
LE_GUILevelEditor' in your level editor scene and add the button name to the '
ADDITIONAL_LEVEL_TAB_BUTTONS' array in the inspector. In this example we add the 'Play' button.
Step 2: Event Registration
The code below will add the OnPlay event handler method to the methods called when the 'Play' 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.AddAdditionalLevelTabButtonHandler("Play", OnPlay);
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 'Play' button event handler could first check if the level is playable. Maybe some important game logic objects are missing, for example the player start position marker. Then it should set some variable that will indicate your level loader, which level it should load as soon as the game scene is loaded (more information on
how to load a level here). Finally, the game scene would be loaded.
private void OnPlay(object p_sender, System.EventArgs p_args)
{
...
...
Application.LoadLevel(1);
}