Save Level

Documentation for Unity Asset Store version v1.20

Summary

To get the byte arrays (data & meta) of a level you have to register for the 'LE_EventInterface.OnSave' event, which is triggered when the save button is clicked in the level editor.

Step 1: Event Registration

Register for the 'LE_EventInterface.OnSave' event. This event will be called when the level is saved. 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 save event, which is called when the level is saved

LE_EventInterface.OnSave += OnSave;

Step 2: Event Handling

The event handler below will access the properties of the 'LE_SaveEvent' EventArgs to get the level's byte arrays. private void OnSave(object p_sender, LE_SaveEvent p_args)
{

    // Get the data and meta data byte arrays from passed EventArgs

    byte[] levelDataAsByteArray = p_args.SavedLevelData;
    byte[] levelMetaAsByteArray = p_args.SavedLevelMeta;

    // You level storage code
    // YOU SHOULD ZIP THE LEVEL DATA!
    // YOU CAN SAVE UP TO 95% DATA VOLUME, AVARAGE SEEMS TO BE AROUND 75% REDUCTION

    ...
}