Skip to main content

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

Use LCKCameraController 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

[SerializeField] private LCKCameraController _cameraController;

public void OnRecordPressed()
{
    _cameraController.ToggleRecording();
}
This disables orientation/quality/top buttons while capture starts, and re-enables on stop or failure.

Switch orientation safely

public void OnOrientationPressed()
{
    _cameraController.ToggleOrientation(); // no-op while capturing
}
Updates ILckService camera orientation, resizes the preview, and recalculates FOV to preserve perceived width in Portrait.

Flip selfie camera / set third-person position

public void OnFlipSelfie() => _cameraController.ProcessSelfieFlip();
public void OnThirdPersonFrontBack() => _cameraController.ProcessThirdPersonPosition();
Flips preview scale and stabilizer orientation for Selfie; toggles in-front/behind for Third Person.

References

Serialized Fields & Options

FieldTypeDescription
_modifyRenderLayerAndCullingMasksboolIf true, automatically moves specified objects to the tablet layer and adjusts camera culling masks so Selfie hides that layer while others show it.
_tabletRenderingLayerstringName of the Unity layer used to hide objects from the Selfie camera (e.g., “LCK Tablet”).
_objectsHiddenFromSelfieCameraList<GameObject>Objects (e.g., tablet model) to assign to the tablet layer.
_qualityConfigScriptableObject (ILckQualityConfig)Provides quality options; updates CameraTrackDescriptor for Recording/Streaming on selection.
_hmdTransformTransformPlayer/HMD anchor; defaults to Camera.main.transform if null.
UI referencesVariousSettings/top buttons, preview monitor RectTransform, LckQualitySelector, per-mode FOV/smoothing/distance controls, and per-mode cameras/stabilizers.

Properties

PropertyTypeDescription
HmdTransformTransformGets/sets HMD anchor; falls back to main camera if unset.
OnCameraModeChangedAction<CameraMode>Event raised after switching Selfie/First/Third Person.
ColliderButtonsInUsestatic boolGlobal 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

MethodReturnsDescription
ToggleRecording()voidStarts/stops recording via ILckService; disables orientation/quality/top buttons during start; re-enables on stop/failure.
ToggleGameAudio()voidToggles game audio capture on/off via ILckService.
ToggleMicrophoneRecording(bool)voidEnables/disables microphone capture via ILckService.
ToggleOrientation()voidSwitches Landscape/Portrait (no-op while capturing); updates ILckService, preview size, and recomputes FOV to preserve horizontal FOV feel.
ProcessSelfieFlip()voidFlips Selfie view 180° and adjusts preview mirroring.
ProcessThirdPersonPosition()voidToggles third-person camera in-front/behind the player.
SetOrientationQualityAndTopButtonsIsDisabledState(bool)voidEnables/disables orientation, quality, and top button UI during capture transitions.
OnCaptureStart(LckResult) / OnCaptureStopped(LckResult)voidRe-enable UI on failure/stop; used with service events for recording/streaming.

Lifecycle & Internals

  • Injects or initialises ILckService (fallback DI setup in Awake if 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