book_4_sparkGenerated
code_blocksInput

Description

The UpdateDrag method is a virtual method in the Editor.BaseDropObject class. It is responsible for updating the drag operation of a drop object within the editor environment. This method is typically called during a drag-and-drop operation to update the position and state of the object being dragged based on the current scene trace result and scene settings.

Usage

To use the UpdateDrag method, you need to have an instance of a class that derives from Editor.BaseDropObject. This method should be overridden in a derived class to provide specific behavior for updating the drag operation. The method takes two parameters:

  • tr: A Sandbox.SceneTraceResult object that contains information about the current trace result in the scene, such as hit position and normal.
  • settings: A Sandbox.Gizmo/SceneSettings object that provides the current settings of the scene, which may affect how the drag operation is visualized or constrained.

Example

public class MyDropObject : Editor.BaseDropObject
{
    public override void UpdateDrag(Sandbox.SceneTraceResult tr, Sandbox.Gizmo.SceneSettings settings)
    {
        // Example implementation of UpdateDrag
        if (tr.Hit)
        {
            // Update the position of the object based on the trace result
            this.GameObject.Position = tr.Position;
        }
    }
}