Class RuntimeResourceRegistry
Provides runtime registration of Unity Resources that can be loaded via Resources.Load. This allows mods to inject custom assets without modifying Unity asset bundles.
public static class RuntimeResourceRegistry
- Inheritance
-
RuntimeResourceRegistry
- Inherited Members
Methods
GetRegisteredAsset(string)
Gets a registered asset.
public static Object? GetRegisteredAsset(string resourcePath)
Parameters
resourcePathstringThe Resources path.
Returns
- Object
The registered asset, or null if not found.
GetRegisteredAsset<T>(string)
Gets a registered asset of a specific type.
public static T? GetRegisteredAsset<T>(string resourcePath) where T : Object
Parameters
resourcePathstringThe Resources path.
Returns
- T
The registered asset cast to type T, or null if not found or wrong type.
Type Parameters
TThe type of asset to retrieve.
IsRegistered(string)
Checks if an asset is registered at the given path.
public static bool IsRegistered(string resourcePath)
Parameters
resourcePathstringThe Resources path to check.
Returns
- bool
True if registered, false otherwise.
RegisterAsset(string, Object)
Registers an asset with a Resources path. After registration, the asset can be loaded via Resources.Load using the provided path.
public static bool RegisterAsset(string resourcePath, Object asset)
Parameters
resourcePathstringThe Resources path (e.g., "MyMod/Accessories/CustomHat").
assetObjectThe Unity Object to register.
Returns
- bool
True if registration was successful.
RegisterAssetForType(string, Object, Type)
Registers an asset with a Resources path for a specific type. This allows a single path to return different assets based on the requested type.
public static bool RegisterAssetForType(string resourcePath, Object asset, Type forType)
Parameters
resourcePathstringThe Resources path.
assetObjectThe Unity Object to register.
forTypeTypeThe type this asset should be returned for.
Returns
- bool
True if registration was successful.
RegisterGameObject(string, GameObject)
Registers a GameObject asset with a Resources path.
public static bool RegisterGameObject(string resourcePath, GameObject gameObject)
Parameters
resourcePathstringThe Resources path.
gameObjectGameObjectThe GameObject to register.
Returns
- bool
True if registration was successful.