> ## Documentation Index
> Fetch the complete documentation index at: https://docs.liv.tv/llms.txt
> Use this file to discover all available pages before exploring further.

# LCKCameraController

> How to control camera modes (Selfie, First Person, Third Person), orientation, FOV, and recording in Unity VR apps using the LIV Camera Kit (LCK) SDK.

## 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

```c# theme={null}
[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

```c# theme={null}
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

```c# theme={null}
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

| 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 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](/api-reference/unity/interfaces/ILckService) — Service interface used for recording, streaming, and camera registration
* [LckCamera](/api-reference/unity/classes/LckCameraController) — Lower-level camera registration if you need custom camera control
* [LckQualityConfig](/api-reference/unity/classes/LckQualityConfig) — Quality preset configuration used by the quality selector
* [CameraTrackDescriptor](/api-reference/unity/structs/CameraTrackDescriptor) — Resolution and format settings updated on quality/orientation changes
