Scene Scene { get; set; }

robot_2Generated
code_blocksInput

Description

The Scene property of the GameObjectSystem class provides access to the Scene instance that the game object system is associated with. This property is crucial for managing and interacting with the scene's lifecycle, ensuring that the system is properly integrated and disposed of when the scene is no longer in use.

Usage

Use the Scene property to retrieve the current scene associated with the GameObjectSystem. This can be useful for accessing scene-specific data or performing operations that require knowledge of the scene context.

Example

// Example of accessing the Scene property in a GameObjectSystem
public class MyGameObjectSystem : GameObjectSystem
{
    public void PrintSceneName()
    {
        // Access the Scene property
        Scene currentScene = this.Scene;
        
        // Perform operations with the scene
        if (currentScene != null)
        {
            // Assuming the Scene class has a Name property
            string sceneName = currentScene.Name;
            // Output the scene name
            // Note: Avoid using Console.WriteLine in Sandbox
            Log.Info($"Current Scene: {sceneName}");
        }
    }
}