From 0432c6d56c539e936a962b6ec0481aa69b5999b8 Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Sun, 3 Jan 2021 19:27:02 +1100 Subject: [PATCH] 3.1.5 * Integrate PR from js6pak --- README.md | 5 ++--- src/ExplorerCore.cs | 5 ++--- src/Helpers/Texture2DHelpers.cs | 4 ++++ src/UI/UIManager.cs | 16 ++++++++++------ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2f38986..727fc19 100644 --- a/README.md +++ b/README.md @@ -50,14 +50,13 @@ 0. Install [BepInEx](https://github.com/BepInEx/BepInEx) for your game. 1. Download the UnityExplorer release for BepInEx IL2CPP or Mono above. 2. Take the `UnityExplorer.BIE.___.dll` file and put it in `[GameFolder]\BepInEx\plugins\` -3. Take the `UnityExplorer\` folder (with `explorerui.bundle`) and put it in `[GameFolder]\Mods\`, so it looks like `[GameFolder]\Mods\UnityExplorer\explorerui.bundle`. -4. In IL2CPP, it is highly recommended to get the base Unity libs for the game's Unity version and put them in the `BepInEx\unhollowed\base\` folder. +3. In IL2CPP, it is highly recommended to get the base Unity libs for the game's Unity version and put them in the `BepInEx\unhollowed\base\` folder. ### MelonLoader 0. Install [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) for your game. 1. Download the UnityExplorer release for MelonLoader IL2CPP or Mono above. -2. Take the contents of the release and put it in the `[GameFolder]\Mods\` folder. It should look like `[GameFolder]\Mods\UnityExplorer.ML.___.dll` and `[GameFolder]\Mods\UnityExplorer\explorerui.bundle`. +2. Take the contents of the release and put it in the `[GameFolder]\Mods\` folder. It should look like `[GameFolder]\Mods\UnityExplorer.ML.___.dll` ## Mod Config diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index b0f6176..ecf526e 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using BepInEx; using UnityEngine; using UnityEngine.SceneManagement; using UnityExplorer.Config; @@ -17,14 +16,14 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.1.4"; + public const string VERSION = "3.1.5"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; #if ML public const string EXPLORER_FOLDER = @"Mods\UnityExplorer"; #elif BIE - public static string EXPLORER_FOLDER = Path.Combine(Paths.ConfigPath, "UnityExplorer"); + public static string EXPLORER_FOLDER = Path.Combine(BepInEx.Paths.ConfigPath, "UnityExplorer"); #endif public static ExplorerCore Instance { get; private set; } diff --git a/src/Helpers/Texture2DHelpers.cs b/src/Helpers/Texture2DHelpers.cs index dc81f51..fdbcfc3 100644 --- a/src/Helpers/Texture2DHelpers.cs +++ b/src/Helpers/Texture2DHelpers.cs @@ -71,7 +71,11 @@ namespace UnityExplorer.Helpers pixels = orig.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); // use full constructor for better compatibility +#if CPP var _newTex = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGBA32, Texture.GenerateAllMips, false, IntPtr.Zero); +#else + var _newTex = new Texture2D((int)rect.width, (int)rect.height); +#endif _newTex.SetPixels(pixels); return _newTex; diff --git a/src/UI/UIManager.cs b/src/UI/UIManager.cs index 90e195e..7d31785 100644 --- a/src/UI/UIManager.cs +++ b/src/UI/UIManager.cs @@ -88,20 +88,24 @@ namespace UnityExplorer.UI } } + private static AssetBundle LoadExplorerUi(string id) + { + return AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore).Assembly.GetManifestResourceStream($"UnityExplorer.Resources.explorerui.{id}.bundle"))); + } + private static byte[] ReadFully(this Stream input) { using (var ms = new MemoryStream()) { - input.CopyTo(ms); + byte[] buffer = new byte[81920]; + int read; + while ((read = input.Read(buffer, 0, buffer.Length)) != 0) + ms.Write(buffer, 0, read); + return ms.ToArray(); } } - private static AssetBundle LoadExplorerUi(string id) - { - return AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore).Assembly.GetManifestResourceStream($"UnityExplorer.Resources.explorerui.{id}.bundle"))); - } - private static void LoadBundle() { AssetBundle bundle = null;