logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityCompositeUiView

    A composite UI view: a container that holds an ordered set of child IViewBase instances (menus, leaf content views, or other composites) laid out by a UnityLayoutBuilder. Because a composite is itself an IViewBase, these nest arbitrarily, so an entire screen — e.g. a nav rail beside a scrollable content column — is one tree of UnityCompositeUiView instances. There are no special-cased regions: any bar or panel (an action bar, a footer, a sidebar) is simply another nested composite child.

    Inheritance
    object
    UnityUiView
    UnityCompositeUiView
    Implements
    ICompositeView
    IViewBase
    IFoundationSettings
    ICrossMenuHost
    IUnityCompositeViewRuntime
    Inherited Members
    UnityUiView._viewModel
    UnityUiView._wrapper
    UnityUiView._useCases
    UnityUiView._audioClips
    UnityUiView._audioPlayerPlayClip
    UnityUiView._audioServiceId
    UnityUiView._eventDispatcherService
    UnityUiView._uiShowSfxKey
    UnityUiView._uiHideSfxKey
    UnityUiView._uiCancelSfxKey
    UnityUiView.Initialize(AudioPlayerPlayClip, string, IEventDispatcherService)
    UnityUiView.InitializeEventDispatcher(IEventDispatcherService)
    UnityUiView.SetEventDispatcherService(IEventDispatcherService)
    UnityUiView.SetWrapper(GameObject)
    UnityUiView.GetWrapper()
    UnityUiView.SetViewModel(UnityUiViewModel)
    UnityUiView.GetViewModel()
    UnityUiView.GetUseCases()
    UnityUiView.GetAudioClips()
    UnityUiView.SetAudioServiceId(string)
    UnityUiView.SetAudioClips(AudioPlayerClip, AudioPlayerClip)
    UnityUiView.SetAudioClips(AudioPlayerClip, AudioPlayerClip, AudioPlayerClip)
    UnityUiView.SetAudioPlayerPlayClip(AudioPlayerPlayClip)
    UnityUiView.SetUseCases(UiUseCases)
    UnityUiView.OnShow(bool)
    UnityUiView.OnDraggingStart()
    UnityUiView.DisableNonSelectedButtons()
    UnityUiView.OnDraggingEnd()
    UnityUiView.EnableAllButtons()
    UnityUiView.CanPlayAudio(string)
    Namespace: Serenity.Ui.Infrastructure.Views
    Assembly: Serenity.UnityUi.Infrastructure.dll
    Syntax
    public class UnityCompositeUiView : UnityUiView, ICompositeView, IViewBase, IFoundationSettings, ICrossMenuHost, IUnityCompositeViewRuntime
    Remarks

    In STACK mode every child shows together. In SWITCHER mode only the active child shows — this is the content area a navigation rail drives: a nav option fires an activation signal and the owning composite calls ActivateChild(string) to swap panels while the rail (a sibling stack region) stays visible.

    This view implements ICompositeView so the business layer can coordinate it without referencing Unity. It owns child registration, the show/hide/activate cascade, the remount-on-show lifecycle of shared (hosted) views, the scroll-layout refresh, and cross-region input routing (see GetFocusableRegions()). The reasoning behind each of those lives in a named collaborator — CompositeFocusRouter, HostedChildManager and UnityLayoutBuilder — so what remains here is the view surface that wires them up.

    Constructors

    UnityCompositeUiView()

    Declaration
    public UnityCompositeUiView()

    Properties

    ContentMode

    The content presentation mode of this composite.

    Declaration
    public ContainerContentMode ContentMode { get; }
    Property Value
    Type Description
    ContainerContentMode

    CrossMenuNavigation

    Whether this composite is configured for cross-menu focus traversal.

    Declaration
    public bool CrossMenuNavigation { get; }
    Property Value
    Type Description
    bool

    IsAlwaysShowingContent

    Whether this composite's default content is shown on first show (vs starting blank).

    Declaration
    public bool IsAlwaysShowingContent { get; }
    Property Value
    Type Description
    bool

    Methods

    ActivateChild(string)

    Declaration
    public void ActivateChild(string childViewId)
    Parameters
    Type Name Description
    string childViewId

    AddChild(IViewBase)

    Registers a child view so it participates in this composite's show/hide cascade.

    Declaration
    public void AddChild(IViewBase child)
    Parameters
    Type Name Description
    IViewBase child

    The child view to add.

    GetActiveChildId()

    Declaration
    public string GetActiveChildId()
    Returns
    Type Description
    string

    GetChildViewIds()

    Declaration
    public IReadOnlyList<string> GetChildViewIds()
    Returns
    Type Description
    IReadOnlyList<string>

    GetChildren()

    Gets the registered child views in layout order.

    Declaration
    public IReadOnlyList<IViewBase> GetChildren()
    Returns
    Type Description
    IReadOnlyList<IViewBase>

    A read-only view over the children.

    GetContentRoot()

    Gets the transform under which children are parented.

    Declaration
    public Transform GetContentRoot()
    Returns
    Type Description
    Transform

    The content-root transform, or this view's transform if none was set.

    GetFocusableRegions()

    The child views that can receive input focus (used by region-routing controllers).

    Declaration
    public IReadOnlyList<IViewBase> GetFocusableRegions()
    Returns
    Type Description
    IReadOnlyList<IViewBase>

    In switcher mode, the single active child; in stack mode, all children. Children that are themselves composites are returned as-is so a controller can recurse.

    GetInputView()

    The leaf menu this composite currently routes input to, or null when it routes none (input then falls back to the menu service's current view, or to a nested composite found separately).

    Declaration
    public IViewBase GetInputView()
    Returns
    Type Description
    IViewBase

    The focused leaf menu as an IViewBase, or null.

    Hide()

    Hides every child view and then hides this composite.

    Declaration
    public override void Hide()

    NotifyHostedChildResized()

    Rebuilds the scroll layout after a mounted hosted child re-measured (keeps the current scroll position).

    Declaration
    public void NotifyHostedChildResized()

    RegisterHostedChild(IViewBase, IHostableView, Transform, UiAnchorType, LayoutSize, bool)

    Registers a hosted child (a shared view instance, e.g. a menu) for remount-on-show: it is only reparented into this composite while shown, then restored to originalParent — so it is never trapped under an inactive composite and stays usable on its own.

    Declaration
    public void RegisterHostedChild(IViewBase child, IHostableView hostable, Transform originalParent, UiAnchorType viewAlignment, LayoutSize size, bool parentHorizontal)
    Parameters
    Type Name Description
    IViewBase child

    The hosted view instance (also added via AddChild(IViewBase) for the cascade).

    IHostableView hostable

    The hosting hooks for child.

    Transform originalParent

    The transform the view is parented under when not hosted (e.g. the canvas).

    UiAnchorType viewAlignment

    Where the view is anchored within its slot while hosted.

    LayoutSize size

    The CSS-style main-axis size declared for the child's slot.

    bool parentHorizontal

    True when this composite's layout main axis is horizontal.

    SetContentConfig(bool, bool)

    Sets the content-display + initial-focus configuration. isAlwaysShowingContent makes a SWITCHER show its default child on first show (vs blank); focusInitialView routes initial input to that content (vs a sibling nav rail).

    Declaration
    public void SetContentConfig(bool isAlwaysShowingContent, bool focusInitialView)
    Parameters
    Type Name Description
    bool isAlwaysShowingContent

    Show the default child on first show.

    bool focusInitialView

    Give the default content initial input focus.

    SetContentMode(ContainerContentMode)

    Sets the container content mode (stack vs switcher).

    Declaration
    public void SetContentMode(ContainerContentMode contentMode)
    Parameters
    Type Name Description
    ContainerContentMode contentMode

    The content presentation mode.

    SetContentRoot(GameObject)

    Sets the transform under which children are parented — either this view's own object or, when the layout is scrollable, the generated scroll content. Also used as the show/hide wrapper.

    Declaration
    public void SetContentRoot(GameObject contentRoot)
    Parameters
    Type Name Description
    GameObject contentRoot

    The content-root GameObject produced by the layout builder.

    SetCrossMenuConfig(bool, bool)

    Enables cross-menu focus traversal between this STACK's menu children (up/down at boundaries).

    Declaration
    public void SetCrossMenuConfig(bool enabled, bool wrapAround)
    Parameters
    Type Name Description
    bool enabled

    Whether traversal is on.

    bool wrapAround

    Whether traversal wraps the whole stack vs stops at the ends.

    SetHostedChildManager(HostedChildManager)

    Injects the hosted-child lifecycle manager (called by the factory at build time).

    Declaration
    public void SetHostedChildManager(HostedChildManager manager)
    Parameters
    Type Name Description
    HostedChildManager manager

    The manager owning mount/release for this composite's hosted children.

    SetInitialActiveChild(string)

    Sets the initially active child for switcher mode; empty means start with none shown.

    Declaration
    public void SetInitialActiveChild(string childViewId)
    Parameters
    Type Name Description
    string childViewId

    The id of the child to activate on first show, or empty for none.

    SetInputActive(bool)

    Sets whether this composite's subtree may receive input. An ancestor (e.g. a SWITCHER whose nav rail holds focus) calls this to suppress its inactive content.

    Declaration
    public void SetInputActive(bool active)
    Parameters
    Type Name Description
    bool active

    True to allow input within this subtree.

    Show()

    Shows this composite and cascades the show to the appropriate children.

    Declaration
    public override void Show()

    SubscribeToEventDispatcherEvents()

    Composites manage no event-dispatcher subscriptions of their own; activation is coordinated by the composite-view service and children handle their own events.

    Declaration
    public override void SubscribeToEventDispatcherEvents()
    Overrides
    UnityUiView.SubscribeToEventDispatcherEvents()

    TryMoveFocus(IFocusableMenuView, bool)

    Declaration
    public bool TryMoveFocus(IFocusableMenuView current, bool forward)
    Parameters
    Type Name Description
    IFocusableMenuView current
    bool forward
    Returns
    Type Description
    bool

    Implements

    ICompositeView
    IViewBase
    IFoundationSettings
    ICrossMenuHost
    IUnityCompositeViewRuntime
    In this article
    © 2026 Serenity. All Rights Reserved