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[]>)

    Initializes the provider.

    Declaration
    public UnityHudDefinitionProvider(Func<UnityHudDefinition[]> hudLoader = 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.

    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