Description
The MousePosition
property of the SceneViewportWidget
class provides the current position of the mouse cursor within the scene viewport. This property is static, meaning it is shared across all instances of SceneViewportWidget
and can be accessed without creating an instance of the class.
The position is represented as a Vector2
, which contains the X and Y coordinates of the mouse cursor relative to the viewport's origin (top-left corner).
Usage
To access the current mouse position within the scene viewport, use the MousePosition
property directly from the SceneViewportWidget
class. This can be useful for implementing custom interactions or UI elements that respond to mouse movements.
Example
// Example of accessing the MousePosition property
Vector2 currentMousePosition = SceneViewportWidget.MousePosition;
// Use the mouse position for custom logic
if (currentMousePosition.x > 100 && currentMousePosition.y > 100)
{
// Perform some action when the mouse is in a specific area
}