logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityGameCameraService

    Unity implementation of IGameCameraService. A plain class (no MonoBehaviour — no per-frame work is needed): owns a registry of UnityEngine.Camera instances, resolves which one is "active" right now, and drives exclusive switching, split-screen layout and (optionally) UnityEngine.AudioListener ownership.

    Cinemachine-agnostic by construction: switching only ever disables/enables the UnityEngine.Camera COMPONENT, never the GameObject, so a CinemachineBrain (or any other sibling component/rig script) on the same object keeps running untouched.

    Inheritance
    object
    UnityGameCameraService
    Implements
    IGameCameraService
    IDisposable
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameCamera.Infrastructure.Services
    Assembly: Serenity.UnityGameCamera.Infrastructure.dll
    Syntax
    public class UnityGameCameraService : IGameCameraService, IDisposable

    Constructors

    UnityGameCameraService(IGameCameraSettings, IEventDispatcherService, ILogService)

    Initializes a new instance of the UnityGameCameraService class.

    Declaration
    public UnityGameCameraService(IGameCameraSettings settings, IEventDispatcherService eventDispatcherService, ILogService logService)
    Parameters
    Type Name Description
    IGameCameraSettings settings

    Configuration for discovery, default split-screen layout, audio-listener management and discovery exclusions. May be null — internal defaults are used (auto-discovery on, two-player Horizontal layout, audio-listener management off, no excluded layers).

    IEventDispatcherService eventDispatcherService

    Dispatcher used to broadcast ActiveCameraChangedSignal and SplitScreenChangedSignal. May be null; the service works silently without one.

    ILogService logService

    Logging service. May be null.

    Methods

    ActivateSplitScreen(SplitScreenLayout)

    Declaration
    public void ActivateSplitScreen(SplitScreenLayout layout)
    Parameters
    Type Name Description
    SplitScreenLayout layout

    AssignCameraToPlayer(int, object)

    Declaration
    public void AssignCameraToPlayer(int playerIndex, object camera)
    Parameters
    Type Name Description
    int playerIndex
    object camera

    ClearActiveCamera()

    Declaration
    public void ClearActiveCamera()

    ClearActiveCameraOverride()

    Declaration
    public void ClearActiveCameraOverride()

    DeactivateSplitScreen()

    Declaration
    public void DeactivateSplitScreen()

    Dispose()

    Unsubscribes from UnityEngine.SceneManagement.SceneManager.sceneLoaded.

    Declaration
    public void Dispose()

    GetActiveCamera()

    Declaration
    public object GetActiveCamera()
    Returns
    Type Description
    object

    GetPlayerAssignments()

    Declaration
    public IReadOnlyList<PlayerViewportAssignment> GetPlayerAssignments()
    Returns
    Type Description
    IReadOnlyList<PlayerViewportAssignment>

    GetRegisteredCameras()

    Declaration
    public IReadOnlyList<object> GetRegisteredCameras()
    Returns
    Type Description
    IReadOnlyList<object>

    RegisterCamera(object)

    Declaration
    public void RegisterCamera(object camera)
    Parameters
    Type Name Description
    object camera

    Reset()

    Declaration
    public void Reset()

    SetActiveCamera(object)

    Declaration
    public void SetActiveCamera(object camera)
    Parameters
    Type Name Description
    object camera

    SetActiveCameraOverride(object)

    Declaration
    public void SetActiveCameraOverride(object camera)
    Parameters
    Type Name Description
    object camera

    SetPlayerViewport(int, ViewportRect)

    Declaration
    public void SetPlayerViewport(int playerIndex, ViewportRect rect)
    Parameters
    Type Name Description
    int playerIndex
    ViewportRect rect

    SetSplitScreenLayout(SplitScreenLayout)

    Declaration
    public void SetSplitScreenLayout(SplitScreenLayout layout)
    Parameters
    Type Name Description
    SplitScreenLayout layout

    UnassignPlayer(int)

    Declaration
    public void UnassignPlayer(int playerIndex)
    Parameters
    Type Name Description
    int playerIndex

    UnregisterCamera(object)

    Declaration
    public void UnregisterCamera(object camera)
    Parameters
    Type Name Description
    object camera

    Implements

    IGameCameraService
    IDisposable
    In this article
    © 2026 Serenity. All Rights Reserved