Sfoglia il codice sorgente

Remove text asset loading attempts

Bepis 6 anni fa
parent
commit
e42ebf14c1

+ 0 - 9
Plugins/ResourceRedirector/AssetLoader.cs

@@ -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
Plugins/ResourceRedirector/Hooks.cs

@@ -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());
-            }
         }
     }
 }

+ 0 - 11
Plugins/ResourceRedirector/ResourceRedirector.cs

@@ -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