Description
The ScenePosition
property of the GraphicsHoverEvent
struct provides the position of the mouse cursor in the scene's coordinate space during a hover event. This property is useful for determining where in the scene the hover event occurred, allowing for precise interaction with scene elements.
Usage
To use the ScenePosition
property, access it from an instance of GraphicsHoverEvent
. This property returns a Vector2
representing the x and y coordinates in the scene's coordinate system.
Example
// Example of accessing the ScenePosition property
public void OnGraphicsHover(GraphicsHoverEvent hoverEvent)
{
Vector2 scenePos = hoverEvent.ScenePosition;
// Use scenePos to determine interaction logic
// For example, check if the position is within a certain area
if (IsWithinTargetArea(scenePos))
{
// Perform some action
}
}
private bool IsWithinTargetArea(Vector2 position)
{
// Define the target area
Vector2 targetAreaMin = new Vector2(10, 10);
Vector2 targetAreaMax = new Vector2(50, 50);
return position.x >= targetAreaMin.x && position.x <= targetAreaMax.x &&
position.y >= targetAreaMin.y && position.y <= targetAreaMax.y;
}