WKLib 0.0.1
A modding library for White Knuckle
Loading...
Searching...
No Matches
WKLib.API.Assets.AssetService Class Reference

Loads and caches AssetBundles and assets, scoped by ModContext to avoid collisions. More...

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.

Returns
AssetBundle | null

 
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.

Returns
Sprite | null

 
Sprite LoadPngAsSprite (string pngFileName)
 Convenience: Create a Sprite from a PNG filename.
 

Detailed Description

Loads and caches AssetBundles and assets, scoped by ModContext to avoid collisions.

Constructor & Destructor Documentation

◆ AssetService()

WKLib.API.Assets.AssetService.AssetService ( WKLibAPI API)

Member Function Documentation

◆ FindLevelsByName()

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)

◆ LoadAllLevelsFromBundle()

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.

◆ LoadBundleRelativeAsync()

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.

Returns
AssetBundle | null

◆ LoadGameModeFromBundle()

async Task< M_Gamemode > WKLib.API.Assets.AssetService.LoadGameModeFromBundle ( AssetBundle bundle,
string assetName,
IProgress< float > progress = null )

Loads a gamemode from an asset bundle.

Returns
M_Gamemode | null

◆ LoadPngAsSprite()

Sprite WKLib.API.Assets.AssetService.LoadPngAsSprite ( string pngFileName)

Convenience: Create a Sprite from a PNG filename.

◆ LoadPngAsSpriteRelative()

Sprite WKLib.API.Assets.AssetService.LoadPngAsSpriteRelative ( string relativePngPath)

Loads a PNG as a Sprite relative to the mod folder.

Returns
Sprite | null

◆ UnloadAllBundles()

void WKLib.API.Assets.AssetService.UnloadAllBundles ( bool unloadAllLoadedObjects = false)

Unloads all bundles loaded by this mod.

◆ UnloadBundleRelative()

void WKLib.API.Assets.AssetService.UnloadBundleRelative ( string relativePath,
bool unloadAllLoadedObjects = false )

Unloads a specific bundle for this mod.


The documentation for this class was generated from the following file: