mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add load bundle method
This commit is contained in:
parent
9233d103ac
commit
43d70b21d9
@ -98,13 +98,9 @@ namespace NewHorizons.Utility.Files
|
||||
/// </summary>
|
||||
public static bool AreRequiredAssetsLoaded() => _loadingBundles.Count == 0;
|
||||
|
||||
public static T Load<T>(string assetBundleRelativeDir, string pathInBundle, IModBehaviour mod) where T : UnityEngine.Object
|
||||
public static AssetBundle LoadBundle(string assetBundleRelativeDir, IModBehaviour mod, bool keepLoaded = false)
|
||||
{
|
||||
string key = Path.GetFileName(assetBundleRelativeDir);
|
||||
T obj;
|
||||
|
||||
try
|
||||
{
|
||||
AssetBundle bundle;
|
||||
|
||||
if (AssetBundles.ContainsKey(key))
|
||||
@ -121,9 +117,20 @@ namespace NewHorizons.Utility.Files
|
||||
return null;
|
||||
}
|
||||
|
||||
AssetBundles[key] = (bundle, false);
|
||||
AssetBundles[key] = (bundle, keepLoaded);
|
||||
}
|
||||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
public static T Load<T>(string assetBundleRelativeDir, string pathInBundle, IModBehaviour mod) where T : UnityEngine.Object
|
||||
{
|
||||
T obj;
|
||||
|
||||
try
|
||||
{
|
||||
AssetBundle bundle = LoadBundle(assetBundleRelativeDir, mod);
|
||||
|
||||
obj = bundle.LoadAsset<T>(pathInBundle);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user