Description
The OrbitCamera
method is a static extension method for the Gizmo.Instance
class, provided by the Editor.SceneEditorExtensions
class. This method is used to enable orbiting functionality for a camera around a specified gizmo instance within a scene editor environment. It calculates the orbiting behavior based on the input parameters and updates the camera's position accordingly.
Usage
To use the OrbitCamera
method, you need to have a Gizmo.Instance
, a SceneCamera
, and a Widget
representing the canvas. You also need to provide a reference to a float
variable that will store the distance from the camera to the gizmo. This method will return a bool
indicating whether the orbit operation was successful.
Here is how you can call the method:
Gizmo.Instance gizmoInstance = ...; // Your gizmo instance
SceneCamera sceneCamera = ...; // Your scene camera
Widget canvas = ...; // Your canvas widget
float distance = 0.0f;
bool success = gizmoInstance.OrbitCamera(sceneCamera, canvas, ref distance);
Example
Gizmo.Instance gizmoInstance = new Gizmo.Instance();
SceneCamera sceneCamera = new SceneCamera();
Widget canvas = new Widget();
float distance = 0.0f;
bool success = gizmoInstance.OrbitCamera(sceneCamera, canvas, ref distance);
if (success)
{
// Orbiting was successful, you can use the updated distance
Console.WriteLine($"Camera is orbiting at a distance of {distance}.");
}
else
{
// Handle the failure case
Console.WriteLine("Failed to orbit the camera.");
}