Perform Actions After Level Object Placement

Documentation for Unity Asset Store version v1.20

Summary

With the 'LE_EventInterface.OnObjectPlaced' event you can realise features like a general object count limit for each level or a shop system that reduces the players money when an object is placed. To limit further object placement take a look at this article.

Step 1: Event Registration

Register for the 'LE_EventInterface.OnObjectPlaced' event. This event will be called every time a new object is placed through drag and drop or duplicate within the object editor. Keep in mind that you also should unregister the event handler when your script gets destroyed otherwise a memory leak could occur. using LE_LevelEditor.Events;

// Register for the load event, which is called when the level is loaded

LE_EventInterface.OnObjectPlaced+= OnObjectPlaced;

Step 2: Event Handling

In the event handler you could increase some object counter or reduce the ingame money of the user. For example you could limit the overall number of object per level. You could also decrease the money of the user and disallow further object placement when all money is used. To disallow further object placement take a look at this article. private void OnObjectPlaced(object p_sender, LE_ObjectPlacedEvent p_args)
{

    // do something here. To get a reference to the placed object take a look at the LE_ObjectPlacedEvent event args

    ...
};