Description
The Trace
property of the EditorTool
class provides a mechanism to create 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, facilitating interactions such as selection or manipulation of scene objects.
Usage
To use the Trace
property, you typically access it within an instance of an EditorTool
derived class. The property returns a SceneTrace
object, which can be used to gather information about the scene at the cursor's location.
Example usage:
public class MyCustomTool : EditorTool
{
public override void OnUpdate()
{
// Perform a trace using the current mouse cursor position
SceneTrace traceResult = this.Trace;
if (traceResult.Hit)
{
// Handle the trace result, e.g., highlight the object
GameObject hitObject = traceResult.Entity;
// Perform operations on hitObject
}
}
}
Example
public class MyCustomTool : EditorTool
{
public override void OnUpdate()
{
// Perform a trace using the current mouse cursor position
SceneTrace traceResult = this.Trace;
if (traceResult.Hit)
{
// Handle the trace result, e.g., highlight the object
GameObject hitObject = traceResult.Entity;
// Perform operations on hitObject
}
}
}