Class DebugCamera
A drop-in free-fly debug camera. Add it to any UnityEngine.Camera (or use the
Scylla/Tools/Add Debug Camera to Scene menu) to navigate a scene in Play mode with configurable
keyboard and mouse controls, framerate-independent smoothing, and an optional orbit mode
that circles a target. It is a self-contained Core utility with no dependency on the
Scylla Camera module or the Scylla Input module.
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/Debug Camera")]
[RequireComponent(typeof(Camera))]
[DisallowMultipleComponent]
public sealed class DebugCamera : MonoBehaviour
Remarks
Input is read through Unity's Input System (Keyboard.current / Mouse.current),
compiled only when the SCYLLA_HAS_INPUTSYSTEM define is present (the Input System
package is installed). Without it the component is inert and logs a single warning.
Movement and looking are active only while the cursor is captured. Click the view to
capture, and press Escape, the toggle key, or switch away from the application to release.
Set Require Cursor Lock to false to drive the camera without locking. The camera
updates on UnityEngine.Time.unscaledDeltaTime, so it keeps working while the
game is paused (UnityEngine.Time.timeScale is zero), and all per-frame work
is allocation-free.
Methods
CaptureHome()
Captures the current transform pose and field of view as the home that the reset key restores. Call at runtime after positioning the camera where "home" should be.
Declaration
public void CaptureHome()
ComputeOrbitPosition(Vector3, float, float, float)
Computes the world position of an orbit camera at the given spherical coordinates
around targetPosition. The camera looking direction is
Quaternion.Euler(pitch, yaw, 0), which faces the target from this position.
Declaration
public static Vector3 ComputeOrbitPosition(Vector3 targetPosition, float yaw, float pitch, float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | targetPosition | The pivot the camera orbits. |
| float | yaw | Azimuth angle in degrees. |
| float | pitch | Elevation angle in degrees. |
| float | distance | Distance from the pivot. |
Returns
| Type | Description |
|---|---|
| Vector3 | The world-space camera position. |
ComputeSmoothingFactor(float, float)
Returns the framerate-independent interpolation factor that moves a value ~99% of the
way to its target over smoothTime seconds. Derived from
1 - e^(ln(0.01) / smoothTime * deltaTime), so a fixed smoothTime
produces the same feel regardless of frame rate.
Declaration
public static float ComputeSmoothingFactor(float smoothTime, float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | smoothTime | Seconds to reach ~99% of the target. Values at or below zero snap instantly (return 1). |
| float | deltaTime | The frame delta time. |
Returns
| Type | Description |
|---|---|
| float | An interpolation factor in the range |