logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityModalComponentFactory

    Factory class for creating Unity modal UI components.
    Handles instantiation of modal components from templates and manages option value updates.
    Integrates with game settings service to persist option changes and validate value ranges.

    Inheritance
    object
    UnityModalComponentFactory
    Implements
    IUiComponentFactory
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Modal.Infrastructure.Views.Factories
    Assembly: Serenity.UnityModal.Infrastructure.dll
    Syntax
    public class UnityModalComponentFactory : IUiComponentFactory

    Constructors

    UnityModalComponentFactory(IGameSettingsService)

    Initializes a new instance of the UnityModalComponentFactory.
    Sets up dependency on the game settings service for option value management.

    Declaration
    public UnityModalComponentFactory(IGameSettingsService gameSettingsService)
    Parameters
    Type Name Description
    IGameSettingsService gameSettingsService

    Service for reading and writing game settings.

    Methods

    CreateUiComponent<Element, Parameters, Actions>(Parameters, Actions, IFoundationViewElement, ILogService)

    Creates a UI component instance from the provided template and parameters.
    Instantiates a GameObject from the template and initializes the component with the given parameters and actions.
    Validates template availability and ensures proper component setup before returning the created element.

    Declaration
    public Element CreateUiComponent<Element, Parameters, Actions>(Parameters parameters, Actions actions, IFoundationViewElement template, ILogService logService) where Element : IFoundationViewElement where Parameters : IUiComponentParameters where Actions : IUiComponentActions
    Parameters
    Type Name Description
    Parameters parameters

    Configuration parameters for the UI component.

    Actions actions

    Actions that define component behavior.

    IFoundationViewElement template

    The template foundation view element to instantiate from.

    ILogService logService

    Service for logging operations.

    Returns
    Type Description
    Element

    The created UI component element.

    Type Parameters
    Name Description
    Element

    The type of foundation view element to create.

    Parameters

    The type of UI component parameters.

    Actions

    The type of UI component actions.

    Exceptions
    Type Condition
    Exception

    Thrown when unsupported element type or null template is provided.

    Exception

    Thrown when GameObject instantiation fails.

    InvalidOperationException

    Thrown when component retrieval fails.

    SetOptionValue(UiOption, string)

    Sets the value of a UI option and persists it through the game settings service.
    Handles type conversion and validation based on the option's value type.
    Enforces minimum and maximum value constraints when specified in game settings.
    Supports FLOAT, INT, BOOL, and STRING value types with appropriate formatting.

    Declaration
    public void SetOptionValue(UiOption option, string value)
    Parameters
    Type Name Description
    UiOption option

    The UI option whose value is being set.

    string value

    The string representation of the new value.

    Implements

    IUiComponentFactory
    In this article
    © 2026 Serenity. All Rights Reserved