Description
The Scene
property of the Editor.EditorTool
class provides access to the current Sandbox.Scene
instance that the editor tool is operating on. This property is essential for interacting with the scene within the editor environment, allowing tools to manipulate and query the scene's state.
Usage
Use the Scene
property to access the current scene in the editor. This can be useful for performing operations such as adding or removing objects, querying scene data, or modifying scene properties.
Note that this property is marked with the JsonIgnore
attribute, indicating that it should not be serialized when converting the object to JSON.
Example
// Example of accessing the Scene property in an EditorTool
public class MyCustomTool : EditorTool
{
public void PerformSceneOperation()
{
// Access the current scene
Scene currentScene = this.Scene;
// Perform operations on the scene
// For example, adding a new GameObject
GameObject newObject = new GameObject();
currentScene.Add(newObject);
}
}