private void RedirectHook(IAssetLoadingContext context) { if (context.Parameters.Name == null || context.Bundle.name == null) { return; } if (typeof(Texture).IsAssignableFrom(context.Parameters.Type)) { string zipPath = $"abdata/{context.Bundle.name.Replace(".unity3d", "", StringComparison.OrdinalIgnoreCase)}/{context.Parameters.Name}.png"; var tex = GetPng(zipPath); if (tex != null) { context.Asset = tex; context.Complete(); return; } } if (context.Parameters.Type == typeof(ExcelData)) { if (TryGetExcelData(context.Bundle.name, context.Parameters.Name, out var excelData)) { context.Asset = excelData; context.Complete(); return; } } if (BundleManager.TryGetObjectFromName(context.Parameters.Name, context.Bundle.name, context.Parameters.Type, out UnityEngine.Object obj)) { context.Asset = obj; context.Complete(); } }
protected bool RedirectHook(string assetBundleName, string assetName, Type type, string manifestAssetBundleName, out AssetBundleLoadAssetOperation result) { string zipPath = $"{manifestAssetBundleName ?? "abdata"}/{assetBundleName.Replace(".unity3d", "")}/{assetName}"; if (type == typeof(Texture2D)) { zipPath = $"{zipPath}.png"; foreach (var archive in Archives) { var entry = archive.GetEntry(zipPath); if (entry != null) { var stream = archive.GetInputStream(entry); result = new AssetBundleLoadAssetOperationSimulation(ResourceRedirector.AssetLoader.LoadTexture(stream, (int)entry.Size)); return(true); } } } if (BundleManager.TryGetObjectFromName(assetName, assetBundleName, type, out UnityEngine.Object obj)) { result = new AssetBundleLoadAssetOperationSimulation(obj); return(true); } result = null; return(false); }
protected bool RedirectHook(string assetBundleName, string assetName, Type type, string manifestAssetBundleName, out AssetBundleLoadAssetOperation result) { string zipPath = $"{manifestAssetBundleName ?? "abdata"}/{assetBundleName.Replace(".unity3d", "", StringComparison.OrdinalIgnoreCase)}/{assetName}"; if (type == typeof(Texture2D)) { zipPath = $"{zipPath}.png"; var tex = GetPng(zipPath); if (tex != null) { result = new AssetBundleLoadAssetOperationSimulation(tex); return(true); } } if (BundleManager.TryGetObjectFromName(assetName, assetBundleName, type, out UnityEngine.Object obj)) { result = new AssetBundleLoadAssetOperationSimulation(obj); return(true); } result = null; return(false); }
protected bool RedirectHook(string assetBundleName, string assetName, Type type, string manifestAssetBundleName, out AssetBundleLoadAssetOperation result) { string zipPath = $"{manifestAssetBundleName ?? "abdata"}/{assetBundleName.Replace(".unity3d", "", StringComparison.OrdinalIgnoreCase)}/{assetName}"; if (type == typeof(Texture2D)) { zipPath = $"{zipPath}.png"; //Only search the archives for a .png that can actually be found if (PngList.TryGetValue(zipPath, out ZipFile archive)) { var entry = archive.GetEntry(zipPath); if (entry != null) { var stream = archive.GetInputStream(entry); var tex = ResourceRedirector.AssetLoader.LoadTexture(stream, (int)entry.Size); if (zipPath.Contains("clamp")) { tex.wrapMode = TextureWrapMode.Clamp; } else if (zipPath.Contains("repeat")) { tex.wrapMode = TextureWrapMode.Repeat; } result = new AssetBundleLoadAssetOperationSimulation(tex); return(true); } } } if (BundleManager.TryGetObjectFromName(assetName, assetBundleName, type, out UnityEngine.Object obj)) { result = new AssetBundleLoadAssetOperationSimulation(obj); return(true); } result = null; return(false); }