logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityUiComponent

    Abstract base class for all Unity-specific UI components in the Serenity foundation.
    Extends the foundation-agnostic FoundationUiComponent to provide Unity-specific functionality including Animator integration and enhanced component lookup mechanisms.
    Implements the Infrastructure layer pattern by bridging between domain interfaces and Unity's GameObject system.

    Inheritance
    object
    UnityUiComponent
    UnityUiBackgroundComponent
    UnityUiInteractableComponent
    Namespace: Serenity.Ui.Infrastructure.Components
    Assembly: Serenity.UnityUi.Infrastructure.dll
    Syntax
    public abstract class UnityUiComponent : FoundationUiComponent

    Constructors

    UnityUiComponent()

    Declaration
    protected UnityUiComponent()

    Fields

    _animators

    Declaration
    protected List<Animator> _animators
    Field Value
    Type Description
    List<Animator>

    Methods

    Awake()

    Unity lifecycle method called when the GameObject is created.
    Initializes the Animator component reference before calling base Awake functionality.
    Ensures proper component setup order for Unity-specific features.

    Declaration
    public override void Awake()

    Initialize(IUiComponentParameters, IUiComponentActions, ILogService)

    Initializes the Unity UI component with required parameters, actions, and services.
    Extends base initialization to include Unity-specific Animator component setup for animation support.
    This method establishes the connection between foundation-agnostic component logic and Unity's rendering system.

    Declaration
    public override void Initialize(IUiComponentParameters parameters, IUiComponentActions uiComponentActions, ILogService logService)
    Parameters
    Type Name Description
    IUiComponentParameters parameters

    Component configuration parameters defining behavior and appearance

    IUiComponentActions uiComponentActions

    Action handlers for component interactions and events

    ILogService logService

    Logging service for debugging and error reporting

    UpdateUiElement<T>(Action<T>, IFoundationViewElement)

    Updates a Unity UI element by finding the appropriate component and executing the provided action.
    Implements a sophisticated component lookup strategy including direct component access, children search, and coroutine-based waiting for dynamic components.
    Handles Unity-specific view element casting and GameObject manipulation while maintaining foundation abstraction.
    Safely handles inactive GameObjects by skipping coroutine-based waiting when the hierarchy is inactive.

    Declaration
    protected override void UpdateUiElement<T>(Action<T> action, IFoundationViewElement viewElement) where T : Component
    Parameters
    Type Name Description
    Action<T> action

    The action to execute on the found component

    IFoundationViewElement viewElement

    The foundation view element containing the Unity GameObject to search

    Type Parameters
    Name Description
    T

    The Unity component type to find and update

    In this article
    © 2026 Serenity. All Rights Reserved