logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityHudDefinitionProvider

    Unity implementation of IHudDefinitionProvider. Resolves UnityHudDefinition assets registered as Addressable under GAME_UI, matching by Guid first, then by Id — the Addressables address is path-derived and never equal to the designer-typed Id, so a lookup cannot go by address.

    Inheritance
    object
    UnityHudDefinitionProvider
    Implements
    IHudDefinitionProvider
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameUi.Infrastructure.Services
    Assembly: Serenity.UnityGameUi.Infrastructure.dll
    Syntax
    public class UnityHudDefinitionProvider : IHudDefinitionProvider
    Remarks

    Loads the label set exactly once per provider lifetime and matches against that single in-memory array. This is a deliberate improvement over UnityFeedbackDefinitionProvider, which calls UnityAssetUtils.FindByGuidBlocking (its own internal load) and then, on a miss, calls LoadAllFromAnyBlocking again — loading the same label set twice on every guid-miss lookup.

    Editor cache staleness: the cache is built from whatever Addressables sees the first time TryGet(string, out IHudDefinition) is called. A HUD asset created or registered while this provider is already alive (e.g. authored during the same Play session) is not picked up until the provider is recreated — practically, the next Play session. This mirrors every other Addressables-backed provider in the project and is an accepted limitation, not a bug.

    Constructors

    UnityHudDefinitionProvider(Func<UnityHudDefinition[]>, ILogService, IReadOnlyList<UnityHudDefinition>)

    Initializes the provider.

    Declaration
    public UnityHudDefinitionProvider(Func<UnityHudDefinition[]> hudLoader = null, ILogService logService = null, IReadOnlyList<UnityHudDefinition> wiredDefinitions = null)
    Parameters
    Type Name Description
    Func<UnityHudDefinition[]> hudLoader

    Loads every candidate HUD asset. Defaults to loading every UnityHudDefinition registered under GAME_UI. Overridable so tests can inject a fake loader and never touch real Addressables.

    ILogService logService

    Where the default load writes the shipped definitions it dropped in favour of the project's adopted twins. Null loads silently, and an injected loader never consults it.

    IReadOnlyList<UnityHudDefinition> wiredDefinitions

    The HUD definitions a designer wired on the composition root. When non-empty the default load returns exactly these; empty falls back to the module label.

    Methods

    TryGet(string, out IHudDefinition)

    Declaration
    public bool TryGet(string idOrGuid, out IHudDefinition definition)
    Parameters
    Type Name Description
    string idOrGuid
    IHudDefinition definition
    Returns
    Type Description
    bool

    Implements

    IHudDefinitionProvider
    In this article
    © 2026 Serenity. All Rights Reserved