Remove text asset loading attempts

This commit is contained in:
Bepis committed 2018-02-24 15:14:43 +11:00
1 parent dfe1422da6
commit e42ebf14c1
3 files changed
+4 -54

No files matched your search

@@ -36,14 +36,5 @@ namespace ResourceRedirector
return tex;
}
public static TextAsset LoadTextAsset(string path)
{
string newPath = $"{Application.dataPath}\\Resources\\{Path.GetFileName(path)}";
File.Copy(path, newPath, true);
return Resources.Load<TextAsset>(Path.GetFileNameWithoutExtension(path));
}
}
}
+4 -34
View File
@@ -3,9 +3,7 @@ using Harmony;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using UnityEngine;
namespace ResourceRedirector
@@ -45,32 +43,30 @@ namespace ResourceRedirector
postfix = new HarmonyMethod(typeof(Hooks).GetMethod("LoadAllAssetPostHook"));
harmony.Patch(original, null, postfix);
//Singleton<Manager.Character>.Instance.chaListCtrl.LoadListInfoAll();
}
public static void LoadAssetPostHook(ref AssetBundleLoadAssetOperation __result, string assetBundleName, string assetName, Type type, string manifestAssetBundleName)
{
//Console.WriteLine($"{assetBundleName} : {assetName} : {type.FullName} : {manifestAssetBundleName ?? ""}");
//BepInLogger.Log($"{assetBundleName} : {assetName} : {type.FullName} : {manifestAssetBundleName ?? ""}");
__result = ResourceRedirector.HandleAsset(assetBundleName, assetName, type, manifestAssetBundleName, ref __result);
}
public static void LoadAssetBundlePostHook(string assetBundleName, bool isAsync, string manifestAssetBundleName)
{
//Console.WriteLine($"{assetBundleName} : {manifestAssetBundleName} : {isAsync}");
//BepInLogger.Log($"{assetBundleName} : {manifestAssetBundleName} : {isAsync}");
}
public static void LoadAssetAsyncPostHook(ref AssetBundleLoadAssetOperation __result, string assetBundleName, string assetName, Type type, string manifestAssetBundleName)
{
//Chainloader.Log($"{assetBundleName} : {assetName} : {type.FullName} : {manifestAssetBundleName ?? ""}", true);
//BepInLogger.Log($"{assetBundleName} : {assetName} : {type.FullName} : {manifestAssetBundleName ?? ""}", true);
__result = ResourceRedirector.HandleAsset(assetBundleName, assetName, type, manifestAssetBundleName, ref __result);
}
public static void LoadAllAssetPostHook(ref AssetBundleLoadAssetOperation __result, string assetBundleName, Type type, string manifestAssetBundleName = null)
{
Chainloader.Log($"{assetBundleName} : {type.FullName} : {manifestAssetBundleName ?? ""}");
//BepInLogger.Log($"{assetBundleName} : {type.FullName} : {manifestAssetBundleName ?? ""}");
if (assetBundleName == "sound/data/systemse/brandcall/00.unity3d" ||
assetBundleName == "sound/data/systemse/titlecall/00.unity3d")
@@ -92,32 +88,6 @@ namespace ResourceRedirector
__result = new AssetBundleLoadAssetOperationSimulation(loadedClips.ToArray());
}
if (type == typeof(TextAsset))
{
string dir = Path.Combine(ResourceRedirector.EmulatedDir, assetBundleName.Replace('/', '\\').Replace(".unity3d", ""));
List<UnityEngine.Object> go = new List<UnityEngine.Object>();
foreach (TextAsset t in __result.GetAllAssets<TextAsset>())
{
string path = Path.Combine(dir, $"{t.name}.txt");
//Chainloader.Log(path);
if (File.Exists(path))
{
Chainloader.Log($"Loading emulated asset {path}");
go.Add(AssetLoader.LoadTextAsset(path));
}
else
{
go.Add(t);
}
}
__result = new AssetBundleLoadAssetOperationSimulation(go.ToArray());
}
}
}
}
@@ -70,17 +70,6 @@ namespace ResourceRedirector
return new AssetBundleLoadAssetOperationSimulation(AssetLoader.LoadAudioClip(path, AudioType.WAV));
}
else if (type == typeof(TextAsset))
{
string path = Path.Combine(dir, $"{assetName}.bytes");
if (!File.Exists(path))
return __result;
BepInLogger.Log($"Loading emulated asset {path}");
return new AssetBundleLoadAssetOperationSimulation(AssetLoader.LoadTextAsset(path));
}
}
//otherwise return normal asset