Skip to content

Game.UI.InGame.CinematicCameraUISystem

Assembly:
Game

Namespace:
Game.UI.InGame

Type:
class

Base:
UISystemBase

Summary:
Manages the in-game cinematic camera UI and the interaction between UI bindings and the cinematic camera systems. Provides functionality to create, edit, play, save/load, and autoplay CinematicCameraSequence assets; handles keyframe capture and manipulation for both camera transforms and photo-mode properties; coordinates input enable/disable between cinematic and orbit/photo-mode controllers; and exposes controller deltas and other values to the UI layer via bindings.


Fields

  • private static readonly string kGroup = "cinematicCamera"
    Used as the UI binding group name sent to the binding system for all triggers, getters and updaters related to cinematic camera UI.

  • private static readonly CinematicCameraSequence.CinematicCameraCurveModifier[] kEmptyModifierArray = Array.Empty<CinematicCameraSequence.CinematicCameraCurveModifier>()
    A reusable empty array used when there are no curves/modifiers to return to avoid allocations.

  • private static readonly string kCaptureKeyframeTutorialTag = "CinematicCameraPanelCaptureKey"
    Tutorial trigger tag used to activate capture-related tutorial hints.

  • private PhotoModeRenderSystem m_PhotoModeRenderSystem
    Reference to the PhotoModeRenderSystem (used to access photo-mode properties for modifier capture and refresh).

  • private TutorialUITriggerSystem m_TutorialUITriggerSystem
    Reference to the TutorialUITriggerSystem used to activate tutorial tips (e.g., when capturing keyframes).

  • private CameraUpdateSystem m_CameraUpdateSystem
    Reference to CameraUpdateSystem for interacting with camera controllers (cinematic/orbit/etc.), reading camera position/rotation and toggling input.

  • private GetterValueBinding<CinematicCameraAsset[]> m_Assets
    Getter binding that supplies the list of available CinematicCameraAsset objects to the UI.

  • private ValueBinding<CinematicCameraAsset> m_LastLoaded
    Value binding used to store the last loaded/created CinematicCameraAsset so the UI can show it.

  • private ValueBinding<CinematicCameraSequence.CinematicCameraCurveModifier[]> m_TransformAnimationCurveBinding
    Binding used to expose camera transform animation curves to the UI curve editor.

  • private ValueBinding<CinematicCameraSequence.CinematicCameraCurveModifier[]> m_ModifierAnimationCurveBinding
    Binding used to expose photo-mode property modifier curves to the UI curve editor.

  • private GetterValueBinding<List<string>> m_AvailableCloudTargetsBinding
    Getter binding that provides the list of storage/cloud targets (e.g., local, cloud) where assets can be saved/loaded.

  • private GetterValueBinding<string> m_SelectedCloudTargetBinding
    Getter binding for the currently selected cloud target name.

  • private CinematicCameraSequence m_ActiveAutoplaySequence
    Reference to a sequence that is currently autoplaying (distinct from activeSequence used for editing).

  • private IGameCameraController m_PreviousController
    Keeps the previously active camera controller so it can be restored after playback stops.

  • private ProxyAction m_MoveAction
    Input action proxy used to read camera move input for controller deltas.

  • private ProxyAction m_ZoomAction
    Input action proxy used to read camera zoom input for controller deltas.

  • private ProxyAction m_RotateAction
    Input action proxy used to read camera rotate input for controller deltas.

  • private bool m_Playing
    Backing field for the playing state (used by the playing property).

Properties

  • public CinematicCameraSequence activeSequence { get; set; } = new CinematicCameraSequence()
    The sequence currently being edited in the UI. Initialized to a new CinematicCameraSequence by default.

  • private float m_TimelinePositionBindingValue => MathUtils.Snap(t, 0.05f)
    Private read-only property used by the UI binding to report the snapped timeline position (snapped to 0.05 increments).

  • private float t { get; set; }
    Current timeline/playback time (in seconds) used when scrubbing or playing a sequence.

  • private bool playing
    Property wrapping m_Playing with custom logic. When set it enables/disables camera input for cinematic/orbit controllers and swaps the active camera controller between cinematic and the previously active controller. Setting this to true will disable typical camera input and route control to cinematic controller; setting false restores previous controller.

Constructors

  • public CinematicCameraUISystem()
    Default constructor. Marked with Preserve attribute in class; initialization occurs in OnCreate (bindings and system references are set up there).

Methods

  • protected virtual OnCreate() : System.Void
    Initializes UI bindings and references to required systems. Adds many Trigger/Call/Getter/Value bindings for timeline control, keyframe editing, asset save/load/delete, cloud targets, curve editor focus, controller delta queries, and loop toggling. Subscribes to AssetDatabase change events and resets the active sequence.

  • public void ToggleModifier(PhotoModeProperty p)
    Captures the current value of one or multiple photo-mode properties (supports multi-property extraction) and adds modifier keyframes at the current timeline time (t). Activates the capture tutorial trigger and updates the modifier animation curve binding so UI reflects new keys.

  • protected override void OnGameLoaded(Context serializationContext)
    Attaches PausePlayback event handlers to the cinematic and orbit camera controllers so camera movement pauses playback. Resets or clears autoplay sequence depending on serialization context. Stops playback and calls Reset to ensure UI and sequence are in a known state.

  • protected override void OnUpdate()
    Updates the system each frame. If playing is true it calls UpdatePlayback to advance time and refresh the active sequence.

  • protected override void OnDestroy()
    Removes PausePlayback handlers from camera controllers and performs base cleanup.

  • private void OnToggleLoop(bool loop)
    Sets activeSequence.loop. If enabling loop it updates modifier and transform curve bindings so the curve editors have the wrapped curves visible.

  • private int OnAddKeyFrame(string id, float time, float value, int curveIndex)
    Adds either a modifier key (when id == "Property") or a transform key (for camera transform curves) at the specified time/value. Updates the corresponding UI binding and returns the added key index.

  • private void Reset()
    Resets activeSequence to default (clears transforms and modifiers) and updates transform/modifier UI bindings.

  • private void OnSetTimelinePosition(float position)
    Sets playing to false, updates t to the supplied position, and refreshes the activeSequence at that time so the camera and properties update to the new frame.

  • private void OnSetPlaybackDuration(float duration)
    Sets activeSequence.playbackDuration to the provided duration, clamped to at least the activeSequence.timelineLength.

  • private void OnCapture(string id, string property)
    Entry point for capture operations from UI: if id == "Property", finds the corresponding PhotoModeProperty and toggles its modifier capture; otherwise captures the active camera transform.

  • private void OnCaptureTransform()
    Captures the current camera position and rotation at the current timeline time (t), adds a camera transform key to activeSequence, and updates the transform curves binding. Also activates the capture tutorial trigger.

  • private void Save(string name, string hash = null)
    Saves the current activeSequence to the selected cloud target. If hash is null a new asset is created; otherwise it overwrites the existing asset with the given hash/guid. Handles local special path resolution for CinematicCameraAsset and updates m_LastLoaded and m_Assets after saving.

  • private void Load(string hash, string storage)
    Loads a CinematicCameraAsset by guid/hash from the specified storage target. If successful, replaces activeSequence with the asset's target sequence and updates relevant bindings.

  • private void Delete(string hash, string storage)
    Deletes a CinematicCameraAsset from the specified storage target and updates the assets binding.

  • private void OnAssetsChanged(AssetChangedEventArgs args)
    Callback for asset changes that triggers m_Assets.Update() on the main thread.

  • private void OnCloudTargetsChanged(AssetChangedEventArgs args)
    Callback for changes to available cloud storage targets that updates the UI bindings for available and selected cloud targets on the main thread.

  • private CinematicCameraAsset[] UpdateAssets()
    Fetches all CinematicCameraAsset entries from the global AssetDatabase and returns them as an array for the m_Assets binding.

  • private void OnRemoveSelectedTransform(int curveIndex, int index)
    Convenience method that removes a transform keyframe by delegating to OnRemoveKeyFrame with id "Transform".

  • private void OnRemoveKeyFrame(string id, int curveIndex, int index)
    Removes either a modifier key (id == "Property") or a transform key depending on id, then updates the relevant binding to reflect the change.

  • private void GetData(string id, out CinematicCameraSequence.CinematicCameraCurveModifier[] modifiers, out ValueBinding<CinematicCameraSequence.CinematicCameraCurveModifier[]> binding)
    Helper that returns either transform modifiers and transform binding (when id == "Position") or property modifiers and modifier binding otherwise. Used by keyframe move operations.

  • private int OnMoveKeyFrame(string id, int curveIndex, int index, Keyframe keyframe)
    Moves a keyframe on the specified modifier/curve. Uses GetData to obtain the correct modifier set and binding. Returns the new key index and updates bindings; also refreshes the sequence at current time t.

  • private void UpdatePlayback()
    Advances the local time t by unscaledDeltaTime, selects the correct sequence (m_ActiveAutoplaySequence if present else activeSequence), enforces loop or stops playback at end, clamps t to playback duration, and refreshes the sequence (camera and photo properties) for the new time.

  • private void PausePlayback()
    Called when camera movement is detected. If currently playing and the active controller is cinematic or photo-mode orbit it will stop playback (set playing = false).

  • private void TogglePlayback()
    Toggles playing. If the current time is near the end of playback duration it resets t to 0 when toggled on.

  • private void StopPlayback()
    Stops playback and resets t to 0, refreshing the sequence so the camera snaps to the start frame.

  • public void Autoplay(CinematicCameraAsset sequence)
    Starts autoplay of the provided CinematicCameraAsset (sets m_ActiveAutoplaySequence, forces loop, resets t, and begins playing).

  • public void StopAutoplay()
    Stops any autoplay sequence, clears m_ActiveAutoplaySequence, resets t and stops playing.

  • private CinematicCameraSequence.CinematicCameraCurveModifier[] GetTransformCurves()
    Returns an array of transform curve modifiers that are valid (curve != null). If sequence has no transforms, returns an empty modifier array to avoid nulls.

  • private float[] GetControllerDelta()
    Reads the Move input action (Vector2) scaled by Time.deltaTime and returns it as a float[2] for the UI to use (e.g., when previewing controller input in editors).

  • private float[] GetControllerPanDelta()
    Reads the Rotate input action (Vector2) scaled by Time.deltaTime and returns it as float[2] for the UI.

  • private float GetControllerZoomDelta()
    Reads the Zoom input action (float) scaled by Time.deltaTime and returns it for the UI.

  • private void OnCurveEditorFocusChange(bool focused)
    Called when the curve editor gains/loses focus. Disables or enables input on orbit and cinematic controllers to prevent camera motion while editing curves.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();

    // Example: Bindings and systems are created in OnCreate by the system itself.
    // This snippet demonstrates programmatic capture of the current camera transform
    // into the activeSequence at time 0 and then starting playback.

    // Ensure sequence is cleared
    activeSequence.Reset();

    // Capture the current camera transform at time 0
    float captureTime = 0f;
    Vector3 pos = m_CameraUpdateSystem.activeCameraController.position;
    Vector3 rot = m_CameraUpdateSystem.activeCameraController.rotation;
    activeSequence.AddCameraTransform(captureTime, pos, rot);

    // Start playback (will route input and camera to cinematic controller)
    TogglePlayback();
}