UIPrefabLoader<TKey> is a generic spawner for UI-flavored prefabs keyed by an arbitrary type (commonly string). Lives in com.cupkekgames.luna runtime; the concrete UIPrefabLoaderString is the most common entry point.
It extends the base PrefabLoader<TKey> (in com.cupkekgames.core) and adds Luna-specific UI integration: FadeOutDestroy(key, duration) — fade out all spawned instances of a key via FadeUIElement before destroying the GameObject. Useful for modals, toasts, popups, etc.
Reach for UIPrefabLoaderString when you want to:
DontDestroyOnLoad)The flagship sample uses it for the news/notification modal in GameUiHub.OpenNotificationHistory():
private static void OpenNotificationHistory()
{
UIPrefabLoaderString.Instance?.Instantiate("NotificationModal");
}public abstract class UIPrefabLoader<TKey> : PrefabLoader<TKey>
{
public void FadeOutDestroy(TKey key, float duration = 0.5f);
}
public class UIPrefabLoaderString : UIPrefabLoader<string>
{
public static UIPrefabLoaderString Instance { get; }
}Inherited from PrefabLoader<TKey> (in core):
| Member | Returns | Description |
|---|---|---|
Instantiate(TKey key) | GameObject | Spawn a new instance of the prefab registered to key. Tracks the instance internally. |
GetInstances(TKey key) | List<GameObject> | All currently-live instances of key. |
ContainsKey(TKey key) | bool | Whether the loader has a prefab registered for key. |
event OnInstanceDestroyed | EventHandler<TKey> | Fired when any instance is destroyed (manually or via FadeOutDestroy). |
UIPrefabLoaderString extends MonoBehaviour (via KeyValueDatabaseMono<TKey, GameObject>). Drop it on a GameObject in your boot scene, configure the _searchFolder (FolderReference) so it auto-populates the prefab database from a folder of UI prefab assets, and assign string keys per-prefab in the inspector.
The LunaUI sample's LunaUIManager.prefab already includes a UIPrefabLoaderString instance — use it as a starting point.
| Variant | Package | Use case |
|---|---|---|
UIPrefabLoader<TKey> | com.cupkekgames.luna | Base — folder-scan prefabs (no Addressables) |
UIPrefabLoaderAddressable<TKey> | com.cupkekgames.addressables | Addressables-keyed loading + caching |
UIPrefabLoaderAddressableString | com.cupkekgames.addressables | Concrete string-keyed addressables variant |
The non-addressable chain lives in Luna so projects without Addressables installed can still use the prefab-loader pattern. See PrefabLoader for the addressable-flavored variants.
Settings
Theme
Light
Contrast
Material
Dark
Dim
Material Dark
System
Sidebar(Light & Contrast only)
Font Family
DM Sans
Wix
Inclusive Sans
AR One Sans
Direction