Description
The Scene
property of the EditorTool
class provides access to the current Scene
being edited or manipulated by the tool. This property is essential for tools that need to interact with or modify the scene's elements, such as adding or removing objects, changing properties, or performing scene-specific operations.
Usage
Use the Scene
property to access the current scene within your custom editor tool. This allows you to perform operations that require knowledge of the scene's state or structure. Since this property is marked with the JsonIgnore
attribute, it will not be serialized when the object is converted to JSON, ensuring that the scene's state is not inadvertently persisted or exposed.
Example
public class MyCustomTool : EditorTool
{
public void ModifyScene()
{
// Access the current scene
Scene currentScene = this.Scene;
// Perform operations on the scene
// For example, adding a new GameObject
GameObject newObject = new GameObject("NewObject");
currentScene.Add(newObject);
}
}