Event Interface

Documentation for Unity Asset Store version v1.20, v1.22 and v1.30

Summary

The event interface ('LE_EventInterface' class) of the Multiplatform Runtime Level Editor allows you to implement the required behaviour for your game. Here you define how your data is stored and loaded, which meta data your levels need. The event based interface minimizes the amount of classes that you need to access this way the editor's code is hidden from the code of your game. This approach allows changes in the editor code, without the need for change in your code. In other words the changes that you will need to make in your code after importing an updated version of the level editor are minimal as long as you use the event interface. I will give my best to keep the 'LE_EventInterface' class as static as possible. Below you will find all public members and methods of the 'LE_EventInterface' class explained briefly. For each member or method I will point you to "how to"-articles showing exemplary use cases.

If you want to make UI related changes, for example changing the left menu or the level tab buttons, then you should take a look at this article.



LE_EventInterface.OnSave

This event will be raised in the level editor when the user clicks on the save button. Using this event will allow you to get a serialized version of your level saved in two byte arrays. See this article for more details.



LE_EventInterface.OnLoad

The Multiplatform Runtime Level Editor provides different mechanics for you to load a level from one or two byte arrays. See this article for more details. This event will be raised in the level editor when the user clicks on the load button.



LE_EventInterface.OnLoadedLevelInEditor

This event will be raised when all loading is done for a level that is loaded for editing via the LE_LoadEvent callbacks.



LE_EventInterface.OnCollectMetaDataBeforeSave

This event allows you to add additional meta data to your levels. For example the gold medal score could be stored in each level. See this article for more details.



LE_EventInterface.OnChangeLevelData

This event will be raised after (or during) any change to the currently edited level. For example it will be raised when the terrain or an object is modified. It will also be raised when the level icon is rendered.



LE_EventInterface.OnObjectSelectedInScene

This event will be raised when an object is selected in the scene by being clicked/touched or through duplicating an object.
Added in v1.22.



LE_EventInterface.OnObjectPlaced

This event will be raised when an object is placed through drag and drop or after duplicating an object. See this article for more details.



LE_EventInterface.OnObjectDragged

This event will be raised when an object is about to be placed through drag and drop. This event is called in every frame in which an object is dragged over something by the player. You can use this event to allow or disallow object placement of a specific level object on a certain location. See this article for more details.



LE_EventInterface.OnTerrainCreated

This event is fired when the terrain was created with the "Create Terrain" button in the level editor. You can get the terrain GameObject from the event arguments.



LE_EventInterface.LevelDataChanged removed in v1.30

This method is called by the internal components of the level editor that make changes to the level. If you add additional GUI that will allow players to make changes to the level then you should call this function after every change.
In version v1.30 I have added the LE_LevelDataChangedEvent class, which is now used for the LE_EventInterface.OnChangeLevelData event. If you have used this method, then refactor your code and invoke LE_EventInterface.OnChangeLevelData directly. Also, you need to pass the type of your change inside the LE_LevelDataChangedEvent argument object.



LE_EventInterface.UnregisterAll

Call this method to remove all references to event handlers that have been set. You should unregister your event handlers one by one or call this function otherwise memory leaks are possible.