|
WKLib 0.2.3
A modding library for White Knuckle
|
Loads and caches AssetBundles and assets, scoped by ModContext to avoid collisions. More...
Collaboration diagram for WKLib.API.Assets.AssetService:Public Member Functions | |
| AssetService (WKLibAPI API) | |
| async Task< AssetBundle > | LoadBundleRelativeAsync (string relativePath, IProgress< float > progress=null) |
| Loads an AssetBundle given a path relative to the mod assembly folder. Caches under a key combining ModID and bundle name.
| |
| void | UnloadBundleRelative (string relativePath, bool unloadAllLoadedObjects=false) |
| Unloads a specific bundle for this mod. | |
| void | UnloadAllBundles (bool unloadAllLoadedObjects=false) |
| Unloads all bundles loaded by this mod. | |
| async Task< Dictionary< string, M_Level > > | LoadAllLevelsFromBundle (AssetBundle bundle, IProgress< float > progress=null) |
| Given a loaded AssetBundle, iterate over every ".prefab" asset name, Load it as a GameObject, check for an M_Level component; if found, add to the returned list. Also logs each M_Level found via WKLog.Debug("LevelName"). If you want to register each prefab in a CL_AssetManager database this method will do it automatically. | |
| List< M_Level > | FindLevelsByName (string nameContains) |
| Returns all M_Level instances whose prefab names contain the given substring. (Uses levelPrefabs from the combined asset database in CL_AssetManager) | |
| async Task< M_Gamemode > | LoadGameModeFromBundle (AssetBundle bundle, string assetName, IProgress< float > progress=null) |
| Loads a gamemode from an asset bundle. | |
| Sprite | LoadPngAsSpriteRelative (string relativePngPath) |
Loads a PNG as a Sprite relative to the mod folder.
| |
| Sprite | LoadPngAsSprite (string pngFileName) |
| Convenience: Create a Sprite from a PNG filename. | |
Public Attributes | |
| readonly string | AssemblyFolder |
Loads and caches AssetBundles and assets, scoped by ModContext to avoid collisions.
Definition at line 21 of file AssetService.cs.
| WKLib.API.Assets.AssetService.AssetService | ( | WKLibAPI | API | ) |
Definition at line 31 of file AssetService.cs.
References WKLib.API.Assets.AssetService.AssemblyFolder.
| List< M_Level > WKLib.API.Assets.AssetService.FindLevelsByName | ( | string | nameContains | ) |
Returns all M_Level instances whose prefab names contain the given substring. (Uses levelPrefabs from the combined asset database in CL_AssetManager)
Definition at line 278 of file AssetService.cs.
| async Task< Dictionary< string, M_Level > > WKLib.API.Assets.AssetService.LoadAllLevelsFromBundle | ( | AssetBundle | bundle, |
| IProgress< float > | progress = null ) |
Given a loaded AssetBundle, iterate over every ".prefab" asset name, Load it as a GameObject, check for an M_Level component; if found, add to the returned list.
Also logs each M_Level found via WKLog.Debug("LevelName").
If you want to register each prefab in a CL_AssetManager database this method will do it automatically.
Definition at line 182 of file AssetService.cs.
| async Task< AssetBundle > WKLib.API.Assets.AssetService.LoadBundleRelativeAsync | ( | string | relativePath, |
| IProgress< float > | progress = null ) |
Loads an AssetBundle given a path relative to the mod assembly folder.
Caches under a key combining ModID and bundle name.
Definition at line 54 of file AssetService.cs.
References WKLib.API.Assets.AssetService.AssemblyFolder.
| async Task< M_Gamemode > WKLib.API.Assets.AssetService.LoadGameModeFromBundle | ( | AssetBundle | bundle, |
| string | assetName, | ||
| IProgress< float > | progress = null ) |
Loads a gamemode from an asset bundle.
Definition at line 295 of file AssetService.cs.
| Sprite WKLib.API.Assets.AssetService.LoadPngAsSprite | ( | string | pngFileName | ) |
Convenience: Create a Sprite from a PNG filename.
Definition at line 379 of file AssetService.cs.
| Sprite WKLib.API.Assets.AssetService.LoadPngAsSpriteRelative | ( | string | relativePngPath | ) |
Loads a PNG as a Sprite relative to the mod folder.
Definition at line 356 of file AssetService.cs.
References WKLib.API.Assets.AssetService.AssemblyFolder.
| void WKLib.API.Assets.AssetService.UnloadAllBundles | ( | bool | unloadAllLoadedObjects = false | ) |
Unloads all bundles loaded by this mod.
Definition at line 149 of file AssetService.cs.
| void WKLib.API.Assets.AssetService.UnloadBundleRelative | ( | string | relativePath, |
| bool | unloadAllLoadedObjects = false ) |
Unloads a specific bundle for this mod.
Definition at line 127 of file AssetService.cs.
| readonly string WKLib.API.Assets.AssetService.AssemblyFolder |
Definition at line 24 of file AssetService.cs.
Referenced by WKLib.API.Assets.AssetService.AssetService(), WKLib.API.Assets.AssetService.LoadBundleRelativeAsync(), and WKLib.API.Assets.AssetService.LoadPngAsSpriteRelative().