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
    IService
    IFoundationSettings
    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, IService, IFoundationSettings, 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.

    Fields

    _disposed

    Declaration
    protected bool _disposed
    Field Value
    Type Description
    bool

    _eventDispatcherService

    Declaration
    protected readonly IEventDispatcherService _eventDispatcherService
    Field Value
    Type Description
    IEventDispatcherService

    _explicitActiveCamera

    Declaration
    protected object _explicitActiveCamera
    Field Value
    Type Description
    object

    _guid

    Declaration
    protected string _guid
    Field Value
    Type Description
    string

    _id

    Declaration
    protected string _id
    Field Value
    Type Description
    string

    _lastResolvedActiveCamera

    Declaration
    protected object _lastResolvedActiveCamera
    Field Value
    Type Description
    object

    _logService

    Declaration
    protected ILogService _logService
    Field Value
    Type Description
    ILogService

    _managedDisabledCameras

    Declaration
    protected readonly HashSet<object> _managedDisabledCameras
    Field Value
    Type Description
    HashSet<object>

    _manualViewports

    Declaration
    protected readonly Dictionary<int, ViewportRect> _manualViewports
    Field Value
    Type Description
    Dictionary<int, ViewportRect>

    _overrideActiveCamera

    Declaration
    protected object _overrideActiveCamera
    Field Value
    Type Description
    object

    _playerCameras

    Declaration
    protected readonly Dictionary<int, object> _playerCameras
    Field Value
    Type Description
    Dictionary<int, object>

    _registry

    Declaration
    protected readonly List<object> _registry
    Field Value
    Type Description
    List<object>

    _settings

    Declaration
    protected readonly IGameCameraSettings _settings
    Field Value
    Type Description
    IGameCameraSettings

    _splitScreenActive

    Declaration
    protected bool _splitScreenActive
    Field Value
    Type Description
    bool

    _splitScreenLayout

    Declaration
    protected SplitScreenLayout _splitScreenLayout
    Field Value
    Type Description
    SplitScreenLayout

    Properties

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    Methods

    ActivateSplitScreen(SplitScreenLayout)

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

    AssignCameraToPlayer(int, object)

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

    ClearActiveCamera()

    Declaration
    public virtual void ClearActiveCamera()

    ClearActiveCameraOverride()

    Declaration
    public virtual void ClearActiveCameraOverride()

    DeactivateSplitScreen()

    Declaration
    public virtual void DeactivateSplitScreen()

    Dispose()

    Unsubscribes from UnityEngine.SceneManagement.SceneManager.sceneLoaded.

    Declaration
    public virtual void Dispose()

    GetActiveCamera()

    Declaration
    public virtual object GetActiveCamera()
    Returns
    Type Description
    object

    GetPlayerAssignments()

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

    GetRegisteredCameras()

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

    RegisterCamera(object)

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

    Reset()

    Declaration
    public virtual void Reset()

    SetActiveCamera(object)

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

    SetActiveCameraOverride(object)

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

    SetPlayerViewport(int, ViewportRect)

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

    SetSplitScreenLayout(SplitScreenLayout)

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

    UnassignPlayer(int)

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

    UnregisterCamera(object)

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

    Implements

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