logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SplitScreenLayoutCalculator

    Pure computation of per-player ViewportRect slots from a player count and a requested SplitScreenLayout. All rects use the engine viewport convention where Y=0 is the BOTTOM of the screen and Y increases upward (Unity's Camera.rect normalized space), not the top-left-origin convention common in UI layout.

    Inheritance
    object
    SplitScreenLayoutCalculator
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameCamera.Domain.Services
    Assembly: Serenity.GameCamera.Domain.dll
    Syntax
    public static class SplitScreenLayoutCalculator
    Remarks

    Edge-case precedence: extreme player counts win over the requested layout. A count of 1 always yields a single full-screen rect regardless of layout; a count above 4 always degrades to one full-screen rect per player (see Compute(int, SplitScreenLayout) for details), even when Quadrants was explicitly requested.

    Methods

    Compute(int, SplitScreenLayout)

    Computes the ordered list of viewport rects for each player, index 0 first.

    Declaration
    public static IReadOnlyList<ViewportRect> Compute(int playerCount, SplitScreenLayout layout)
    Parameters
    Type Name Description
    int playerCount

    Number of active players; must be greater than zero.

    SplitScreenLayout layout

    The requested split-screen layout.

    Returns
    Type Description
    IReadOnlyList<ViewportRect>

    A list of exactly playerCount rects, one per player in player-index order. Behavior by case:

    • playerCount == 1: a single full-screen rect, regardless of layout.
    • playerCount == 2, Vertical: top half then bottom half.
    • playerCount == 2, Horizontal: left half then right half.
    • playerCount == 3: top-left, top-right, bottom-left quadrant slots.
    • playerCount == 4: all four quadrant slots (top-left, top-right, bottom-left, bottom-right).
    • playerCount > 4: degrades to one full-screen rect per player; the caller must assign real rects manually via SetPlayerViewport (an Application-layer API, not part of this slice) since no automatic layout supports more than four viewports.
    • Manual: one full-screen placeholder rect per player, regardless of count; the caller is expected to assign real rects later.
    • Single: one full-screen rect per player, regardless of count; the screen is not split and exclusive display is managed elsewhere.
    • Quadrants requested with a count other than 3 or 4: uses quadrant slots capped at min(playerCount, 4), unless playerCount exceeds 4, in which case the >4 degradation rule takes precedence.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown when playerCount is zero or negative.

    In this article
    © 2026 Serenity. All Rights Reserved