Scene ActiveScene { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The ActiveScene property of the Game class provides access to the currently active Scene in the game. This property is static and can be accessed without instantiating the Game class. It is useful for retrieving information about the current scene, such as its components, objects, and overall state.

Usage

To access the active scene in your game, use the Game.ActiveScene property. This will return a Scene object representing the current scene.

Example

// Access the active scene
Scene currentScene = Game.ActiveScene;

// Example: Iterate through all game objects in the active scene
foreach (GameObject obj in currentScene.GameObjects)
{
    // Perform operations on each game object
    Console.WriteLine(obj.Name);
}