public static AssetBundleLoadAssetOperation HandleAsset(string assetBundleName, string assetName, Type type, string manifestAssetBundleName, ref AssetBundleLoadAssetOperation __result) { foreach (var handler in AssetResolvers) { try { if (handler.Invoke(assetBundleName, assetName, type, manifestAssetBundleName, out AssetBundleLoadAssetOperation result)) { return(result); } } catch { } } //emulate asset load string dir = Path.Combine(EmulatedDir, assetBundleName.Replace('/', '\\').Replace(".unity3d", "")); if (Directory.Exists(dir)) { if (type == typeof(Texture2D)) { string path = Path.Combine(dir, $"{assetName}.png"); if (!File.Exists(path)) { return(__result); } BepInLogger.Log($"Loading emulated asset {path}"); var tex = AssetLoader.LoadTexture(path); if (path.Contains("clamp")) { tex.wrapMode = TextureWrapMode.Clamp; } else if (path.Contains("repeat")) { tex.wrapMode = TextureWrapMode.Repeat; } return(new AssetBundleLoadAssetOperationSimulation(tex)); } else if (type == typeof(AudioClip)) { string path = Path.Combine(dir, $"{assetName}.wav"); if (!File.Exists(path)) { return(__result); } BepInLogger.Log($"Loading emulated asset {path}"); return(new AssetBundleLoadAssetOperationSimulation(AssetLoader.LoadAudioClip(path, AudioType.WAV))); } } string emulatedPath = Path.Combine(EmulatedDir, assetBundleName.Replace('/', '\\')); if (File.Exists(emulatedPath)) { if (!EmulatedAssetBundles.TryGetValue(emulatedPath, out AssetBundle bundle)) { bundle = AssetBundle.LoadFromFile(emulatedPath); EmulatedAssetBundles[emulatedPath] = bundle; } return(new AssetBundleLoadAssetOperationSimulation(bundle.LoadAsset(assetName))); } //otherwise return normal asset return(__result); }