mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Revert "revert load prefab cache cuz i think it already happens"
This reverts commit d0a61ba88d7077fb6b9427fb04e0a1f1b8a21aa9.
This commit is contained in:
parent
ece07be2d6
commit
5beb803835
@ -12,6 +12,7 @@ namespace NewHorizons.Utility.Files
|
||||
public static class AssetBundleUtilities
|
||||
{
|
||||
public static Dictionary<string, (AssetBundle bundle, bool keepLoaded)> AssetBundles = new();
|
||||
private static Dictionary<string, GameObject> _prefabCache = new();
|
||||
|
||||
private static readonly List<AssetBundleCreateRequest> _loadingBundles = new();
|
||||
|
||||
@ -52,6 +53,7 @@ namespace NewHorizons.Utility.Files
|
||||
|
||||
}
|
||||
AssetBundles = AssetBundles.Where(x => x.Value.keepLoaded).ToDictionary(x => x.Key, x => x.Value);
|
||||
_prefabCache.Clear();
|
||||
}
|
||||
|
||||
public static void PreloadBundle(string assetBundleRelativeDir, IModBehaviour mod)
|
||||
@ -113,11 +115,17 @@ namespace NewHorizons.Utility.Files
|
||||
|
||||
public static GameObject LoadPrefab(string assetBundleRelativeDir, string pathInBundle, IModBehaviour mod)
|
||||
{
|
||||
var prefab = Load<GameObject>(assetBundleRelativeDir, pathInBundle, mod);
|
||||
if (_prefabCache.TryGetValue(assetBundleRelativeDir + pathInBundle, out var prefab))
|
||||
return prefab;
|
||||
|
||||
prefab = Load<GameObject>(assetBundleRelativeDir, pathInBundle, mod);
|
||||
|
||||
prefab.SetActive(false);
|
||||
|
||||
ReplaceShaders(prefab);
|
||||
|
||||
// replacing shaders is expensive, so cache it
|
||||
_prefabCache.Add(assetBundleRelativeDir + pathInBundle, prefab);
|
||||
|
||||
return prefab;
|
||||
}
|
||||
@ -213,4 +221,4 @@ namespace NewHorizons.Utility.Files
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user