logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityCharacterService

    Unity MonoBehaviour implementation of ICharacterService. Manages per-character state using a dictionary keyed by CharacterId. Stores archetype SO references for Unity-only data access (prefab, death window).

    Inheritance
    object
    UnityCharacterService
    Implements
    ICharacterService
    IService
    IFoundationSettings
    Namespace: Serenity.Character.Infrastructure.Services
    Assembly: Serenity.UnityCharacter.Infrastructure.dll
    Syntax
    public class UnityCharacterService : MonoBehaviour, ICharacterService, IService, IFoundationSettings

    Constructors

    UnityCharacterService()

    Declaration
    public UnityCharacterService()

    Properties

    AliveCharacterCount

    Declaration
    public int AliveCharacterCount { get; }
    Property Value
    Type Description
    int

    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

    ActivateCharacter(CharacterId)

    Declaration
    public void ActivateCharacter(CharacterId id)
    Parameters
    Type Name Description
    CharacterId id

    ConfigureCharacters(CharacterConfig[])

    Declaration
    public void ConfigureCharacters(CharacterConfig[] configs)
    Parameters
    Type Name Description
    CharacterConfig[] configs

    FinishCharacterDeath(CharacterId)

    Declaration
    public void FinishCharacterDeath(CharacterId id)
    Parameters
    Type Name Description
    CharacterId id

    HitCharacter(CharacterId, int)

    Declaration
    public bool HitCharacter(CharacterId id, int damage = 1)
    Parameters
    Type Name Description
    CharacterId id
    int damage
    Returns
    Type Description
    bool

    InitializeService(ILogService)

    Initializes the service with required dependencies.

    Declaration
    public void InitializeService(ILogService logService)
    Parameters
    Type Name Description
    ILogService logService

    The logging service for diagnostic output.

    RegisterCharacter(CharacterId, object, int)

    Declaration
    public void RegisterCharacter(CharacterId id, object character, int maxHealth)
    Parameters
    Type Name Description
    CharacterId id
    object character
    int maxHealth

    SetCharacterConfigs(ICharacterConfig[])

    Replaces the current archetype configuration with the provided ScriptableObject array. Called by the installer after label-based auto-discovery, or can be called manually. Overrides any previously applied configs (including inspector-assigned ones).

    Declaration
    public void SetCharacterConfigs(ICharacterConfig[] configs)
    Parameters
    Type Name Description
    ICharacterConfig[] configs

    Array of archetype ScriptableObjects to apply. Null entries are skipped.

    TryGetCharacterSO(object, out ICharacterConfig)

    Gets the Unity authoring data for a specific archetype. Provides access to prefab, death window, and other Unity-only fields.

    Declaration
    public bool TryGetCharacterSO(object character, out ICharacterConfig configSO)
    Parameters
    Type Name Description
    object character

    The character to look up.

    ICharacterConfig configSO

    The authoring ScriptableObject if found.

    Returns
    Type Description
    bool

    True if the archetype SO was found.

    TryGetSnapshot(CharacterId, out CharacterSnapshot)

    Declaration
    public bool TryGetSnapshot(CharacterId id, out CharacterSnapshot snapshot)
    Parameters
    Type Name Description
    CharacterId id
    CharacterSnapshot snapshot
    Returns
    Type Description
    bool

    UnregisterCharacter(CharacterId)

    Declaration
    public void UnregisterCharacter(CharacterId id)
    Parameters
    Type Name Description
    CharacterId id

    Implements

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