Description
The SceneRect
property of the Editor.GraphicsItem
class represents the rectangle that defines the boundaries of the graphics item within the scene. This property is of type Sandbox.Rect
, which provides the dimensions and position of the rectangle in the scene's coordinate space.
Usage
Use the SceneRect
property to get or set the rectangle that defines the boundaries of a graphics item within the scene. This can be useful for determining the item's position and size relative to the entire scene, as opposed to its local or parent coordinates.
To access or modify the SceneRect
, you can use the following syntax:
var sceneRect = graphicsItem.SceneRect;
// Modify the SceneRect
graphicsItem.SceneRect = new Rect(new Vector2(0, 0), new Vector2(100, 100));
Example
// Example of accessing and modifying the SceneRect property
Editor.GraphicsItem graphicsItem = new Editor.GraphicsItem();
// Get the current SceneRect
Sandbox.Rect currentSceneRect = graphicsItem.SceneRect;
// Output the current SceneRect dimensions
Vector2 position = currentSceneRect.Position;
Vector2 size = currentSceneRect.Size;
// Set a new SceneRect
graphicsItem.SceneRect = new Sandbox.Rect(new Vector2(10, 10), new Vector2(200, 150));