diff --git a/src/SpaceWarp.Core/API/Loading/Loading.cs b/src/SpaceWarp.Core/API/Loading/Loading.cs index d85b3b0..90d9d31 100644 --- a/src/SpaceWarp.Core/API/Loading/Loading.cs +++ b/src/SpaceWarp.Core/API/Loading/Loading.cs @@ -80,6 +80,21 @@ public static void AddAddressablesLoadingAction(string name, string label, Ac AddGeneralLoadingAction(() => new AddressableAction(name, label, action)); } + /// + /// Registers an action to be done on addressables after addressables have been loaded. Should be added either on Awake() or Start(). + /// Allows to keep asset in memory after loading them. This is useful for textures or UXML templates, for example. + /// + /// The name of the action + /// The addressables label to hook into + /// Indicates if assets should be kept in memory after loading them. + /// The action to be done on each addressables asset + /// The type of asset that this action is done upon + public static void AddAddressablesLoadingAction(string name, string label, bool keepAssets, Action action) + where T : UnityObject + { + AddGeneralLoadingAction(() => new AddressableAction(name, label, keepAssets, action)); + } + private static Action CreateAssetLoadingActionWithExtensions(string subfolder, Func> importFunction, string[] extensions)