System.Action OnMapUnloaded { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The OnMapUnloaded property is an event handler that is invoked when a map has been successfully unloaded from the scene. This property is part of the MapInstance class, which is responsible for managing map loading and unloading within the Sandbox environment.

Usage

To use the OnMapUnloaded event, you can assign a method to it that will be called whenever a map is unloaded. This is useful for performing cleanup operations or updating the game state after a map has been removed from the scene.

Example

// Example of using the OnMapUnloaded event

public class MyGameComponent : Component
{
    private MapInstance mapInstance;

    public MyGameComponent()
    {
        mapInstance = new MapInstance();
        mapInstance.OnMapUnloaded += HandleMapUnloaded;
    }

    private void HandleMapUnloaded()
    {
        // Perform actions needed after the map is unloaded
        Log.Info("Map has been unloaded.");
    }

    public void UnloadCurrentMap()
    {
        mapInstance.UnloadMap();
    }
}