Description
LCKCameraController is a Unity MonoBehaviour that manages the full in-game camera system for LCK. It switches between three virtual cameras (Selfie, First Person, Third Person), applies stabilisation and smoothing, handles FOV and distance adjustments from UI controls, toggles between portrait and landscape orientation, and communicates the active camera and track settings to ILckService. It can also auto-configure culling masks to hide the tablet layer from the Selfie view.
Usage
UseLCKCameraController when you need a ready-made camera rig that handles mode switching, orientation, and recording controls through Unity UI. Add it to a GameObject and assign your UI controls, camera/stabilizer components for each mode, and optionally an ILckQualityConfig ScriptableObject for quality presets.
Toggle recording from a UI button
Switch orientation safely
ILckService camera orientation, resizes the preview, and recalculates FOV to preserve perceived width in Portrait.
Flip selfie camera / set third-person position
References
Serialized Fields & Options
| Field | Type | Description |
|---|---|---|
_modifyRenderLayerAndCullingMasks | bool | If true, automatically moves specified objects to the tablet layer and adjusts camera culling masks so Selfie hides that layer while others show it. |
_tabletRenderingLayer | string | Name of the Unity layer used to hide objects from the Selfie camera (e.g., “LCK Tablet”). |
_objectsHiddenFromSelfieCamera | List<GameObject> | Objects (e.g., tablet model) to assign to the tablet layer. |
_qualityConfig | ScriptableObject (ILckQualityConfig) | Provides quality options; updates CameraTrackDescriptor for Recording/Streaming on selection. |
_hmdTransform | Transform | Player/HMD anchor; defaults to Camera.main.transform if null. |
| UI references | Various | Settings/top buttons, preview monitor RectTransform, LckQualitySelector, per-mode FOV/smoothing/distance controls, and per-mode cameras/stabilizers. |
Properties
| Property | Type | Description |
|---|---|---|
HmdTransform | Transform | Gets/sets HMD anchor; falls back to main camera if unset. |
OnCameraModeChanged | Action<CameraMode> | Event raised after switching Selfie/First/Third Person. |
ColliderButtonsInUse | static bool | Global flag for collider-based UI interactions (not used internally here). |
Camera Modes
- Selfie — parented to the tablet; supports flip (front/back), smoothing/FOV, hides tablet layer from the view.
- First Person — follows HMD (position + slight forward offset), smoothing/FOV, instant snap after mode switch.
- Third Person — orbital camera with height angle and adjustable distance; toggle front/behind; smoothing/FOV.
Key Methods
| Method | Returns | Description |
|---|---|---|
ToggleRecording() | void | Starts/stops recording via ILckService; disables orientation/quality/top buttons during start; re-enables on stop/failure. |
ToggleGameAudio() | void | Toggles game audio capture on/off via ILckService. |
ToggleMicrophoneRecording(bool) | void | Enables/disables microphone capture via ILckService. |
ToggleOrientation() | void | Switches Landscape/Portrait (no-op while capturing); updates ILckService, preview size, and recomputes FOV to preserve horizontal FOV feel. |
ProcessSelfieFlip() | void | Flips Selfie view 180° and adjusts preview mirroring. |
ProcessThirdPersonPosition() | void | Toggles third-person camera in-front/behind the player. |
SetOrientationQualityAndTopButtonsIsDisabledState(bool) | void | Enables/disables orientation, quality, and top button UI during capture transitions. |
OnCaptureStart(LckResult) / OnCaptureStopped(LckResult) | void | Re-enable UI on failure/stop; used with service events for recording/streaming. |
Lifecycle & Internals
- Injects or initialises
ILckService(fallback DI setup inAwakeif missing). - Subscribes to service events to reflect capture state; unsubscribes and stops recording on destroy.
- Optional auto-layer/culling setup hides tablet layer from Selfie, shows it for others.
- Recomputes Portrait FOV to maintain perceived width using the current descriptor’s resolution.
See Also
- ILckService — Service interface used for recording, streaming, and camera registration
- LckCamera — Lower-level camera registration if you need custom camera control
- ILckQualityConfig — Quality preset configuration used by the quality selector
- CameraTrackDescriptor — Resolution and format settings updated on quality/orientation changes