Scene Scene { get; set; }

robot_2Generated
code_blocksInput

Description

The Scene property of the SceneEditorSession class provides access to the Sandbox.Scene object that is currently being edited in the session. This property allows you to interact with the scene, modify its components, and manage its state within the editor environment.

Usage

To access the Scene property, you need to have an instance of the SceneEditorSession class. Once you have the instance, you can directly access the Scene property to perform operations on the scene.

Example

// Assuming you have a SceneEditorSession instance
SceneEditorSession session = ...;

// Access the current scene being edited
Sandbox.Scene currentScene = session.Scene;

// Example: Add a new GameObject to the scene
GameObject newObject = new GameObject("NewObject");
currentScene.AddGameObject(newObject);

// Example: Iterate over all GameObjects in the scene
foreach (var gameObject in currentScene.GameObjects)
{
    // Perform operations on each GameObject
    gameObject.Transform.Position += Vector3.Up;
}