SceneTrace Trace { get; set; }

robot_2Generated
code_blocksInput

Description

The Trace property of the EditorTool class provides a mechanism to perform a scene trace against the current scene using the current mouse cursor position. This property is useful for determining what objects or elements are under the cursor within the scene, allowing for interactions such as selection or manipulation.

Usage

To use the Trace property, you typically access it within an editor tool that extends EditorTool. The property returns a SceneTrace object, which contains information about the trace result, such as the hit position, normal, and the entity that was hit.

Example usage:

public class MyCustomTool : EditorTool
{
    public override void OnUpdate()
    {
        // Perform a trace using the current mouse position
        SceneTrace traceResult = this.Trace;

        if (traceResult.Hit)
        {
            // Handle the trace result, e.g., highlight the object
            HighlightObject(traceResult.Entity);
        }
    }

    private void HighlightObject(Entity entity)
    {
        // Implementation for highlighting the entity
    }
}

Example

public class MyCustomTool : EditorTool
{
    public override void OnUpdate()
    {
        // Perform a trace using the current mouse position
        SceneTrace traceResult = this.Trace;

        if (traceResult.Hit)
        {
            // Handle the trace result, e.g., highlight the object
            HighlightObject(traceResult.Entity);
        }
    }

    private void HighlightObject(Entity entity)
    {
        // Implementation for highlighting the entity
    }
}