diff --git a/README.md b/README.md index 31db5d5..f13ca93 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,34 @@ The standalone release is based on the BepInEx build, so it requires Harmony 2.0 1. Create an instance of Unity Explorer with `UnityExplorer.ExplorerStandalone.CreateInstance();` 2. Optionally subscribe to the `ExplorerStandalone.OnLog` event to handle logging if you wish. +## Issues and contributions + +Both issue reports and PR contributions are welcome in this repository. + +### Issue reporting + +To report an issue with UnityExplorer, please use the following template (as well as any other information / images you can provide). + +Please upload the required log files on [Pastebin](https://pastebin.com/) and include a link to your paste: + +* All reports: Unity's `output_log.txt` or `Player.log`, should be found at `%userprofile%\AppData\LocalLow\[Company]\[Game]\` unless redirected. +* BepInEx: `BepInEx\LogOutput.log` +* MelonLoader: `MelonLoader\Latest.log` + +Template: + +``` +* OS Platform: +* Display resolution: +* Game(s) tested on: +* UnityExplorer version(s) tested: + +* Description of issue: + +* Unity log pastebin link: +* Mod Loader log pastebin link: +``` + ## Features

diff --git a/src/Core/Config/ConfigManager.cs b/src/Core/Config/ConfigManager.cs index a30d839..5e5e287 100644 --- a/src/Core/Config/ConfigManager.cs +++ b/src/Core/Config/ConfigManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using UnityEngine; using UnityExplorer.UI.Main; @@ -45,6 +46,8 @@ namespace UnityExplorer.Core.Config PanelDragger.OnFinishDrag += PanelDragger_OnFinishDrag; MainMenu.OnActiveTabChanged += MainMenu_OnActiveTabChanged; DebugConsole.OnToggleShow += DebugConsole_OnToggleShow; + + InitConsoleCallback(); } internal static void RegisterConfigElement(ConfigElement configElement) @@ -134,6 +137,33 @@ namespace UnityExplorer.Core.Config Last_SceneExplorer_State.Value = showing; } + #region CONSOLE ONEXIT CALLBACK + + internal static void InitConsoleCallback() + { + handler = new ConsoleEventDelegate(ConsoleEventCallback); + SetConsoleCtrlHandler(handler, true); + } + + static bool ConsoleEventCallback(int eventType) + { + // 2 is Console Quit + if (eventType == 2) + Handler.SaveConfig(); + + return false; + } + + static ConsoleEventDelegate handler; + private delegate bool ConsoleEventDelegate(int eventType); + + [DllImport("kernel32.dll", SetLastError = true)] + private static extern bool SetConsoleCtrlHandler(ConsoleEventDelegate callback, bool add); + + #endregion + + #region WINDOW ANCHORS / POSITION HELPERS + // Window Anchors helpers private const string DEFAULT_WINDOW_ANCHORS = "0.25,0.10,0.78,0.95"; @@ -210,5 +240,7 @@ namespace UnityExplorer.Core.Config //ExplorerCore.LogWarning("Exception setting window position: " + ex); } } + + #endregion } } diff --git a/src/Core/Input/CursorUnlocker.cs b/src/Core/Input/CursorUnlocker.cs index bfc6bf1..5027955 100644 --- a/src/Core/Input/CursorUnlocker.cs +++ b/src/Core/Input/CursorUnlocker.cs @@ -125,11 +125,17 @@ namespace UnityExplorer.Core.Input { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; + + if (UIManager.EventSys) + SetEventSystem(); } else { Cursor.lockState = m_lastLockMode; Cursor.visible = m_lastVisibleState; + + if (UIManager.EventSys) + ReleaseEventSystem(); } m_currentlySettingCursor = false; } diff --git a/src/Core/Runtime/Il2Cpp/Il2CppProvider.cs b/src/Core/Runtime/Il2Cpp/Il2CppProvider.cs index c6c4f8c..8d2f920 100644 --- a/src/Core/Runtime/Il2Cpp/Il2CppProvider.cs +++ b/src/Core/Runtime/Il2Cpp/Il2CppProvider.cs @@ -89,10 +89,13 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp internal delegate void d_GetRootGameObjects(int handle, IntPtr list); - public override GameObject[] GetRootGameObjects(Scene scene) => GetRootGameObjects(scene.handle); - - public static GameObject[] GetRootGameObjects(int handle) + public override GameObject[] GetRootGameObjects(Scene scene) { + if (!scene.isLoaded) + return new GameObject[0]; + + int handle = scene.handle; + if (handle == -1) return new GameObject[0]; diff --git a/src/Core/Runtime/Mono/MonoProvider.cs b/src/Core/Runtime/Mono/MonoProvider.cs index f337e50..aec08f8 100644 --- a/src/Core/Runtime/Mono/MonoProvider.cs +++ b/src/Core/Runtime/Mono/MonoProvider.cs @@ -52,6 +52,9 @@ namespace UnityExplorer.Core.Runtime.Mono public override GameObject[] GetRootGameObjects(Scene scene) { + if (!scene.isLoaded) + return new GameObject[0]; + return scene.GetRootGameObjects(); } diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index 5b45b53..a039828 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -12,7 +12,7 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.3.2"; + public const string VERSION = "3.3.3"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; diff --git a/src/Loader/ML/MelonLoaderConfigHandler.cs b/src/Loader/ML/MelonLoaderConfigHandler.cs index c238ee4..5dcc654 100644 --- a/src/Loader/ML/MelonLoaderConfigHandler.cs +++ b/src/Loader/ML/MelonLoaderConfigHandler.cs @@ -69,7 +69,6 @@ namespace UnityExplorer.Loader.ML public override void OnAnyConfigChanged() { - MelonPreferences.Save(); } public override void SaveConfig() diff --git a/src/UI/Main/Home/Inspectors/GameObjects/ChildList.cs b/src/UI/Main/Home/Inspectors/GameObjects/ChildList.cs index 32763a0..28c60bb 100644 --- a/src/UI/Main/Home/Inspectors/GameObjects/ChildList.cs +++ b/src/UI/Main/Home/Inspectors/GameObjects/ChildList.cs @@ -169,7 +169,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); }); ColorBlock mainColors = new ColorBlock(); - RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.07f, 0.07f, 0.07f), + mainColors = RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.07f, 0.07f, 0.07f), new Color(0.2f, 0.2f, 0.2f, 1), new Color(0.05f, 0.05f, 0.05f)); var mainBtn = UIFactory.CreateButton(btnGroupObj, diff --git a/src/UI/Main/Home/Inspectors/GameObjects/ComponentList.cs b/src/UI/Main/Home/Inspectors/GameObjects/ComponentList.cs index 252cadb..51610a6 100644 --- a/src/UI/Main/Home/Inspectors/GameObjects/ComponentList.cs +++ b/src/UI/Main/Home/Inspectors/GameObjects/ComponentList.cs @@ -176,7 +176,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects // Main component button ColorBlock mainColors = new ColorBlock(); - RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.07f, 0.07f, 0.07f), + mainColors = RuntimeProvider.Instance.SetColorBlock(mainColors, new Color(0.07f, 0.07f, 0.07f), new Color(0.2f, 0.2f, 0.2f, 1), new Color(0.05f, 0.05f, 0.05f)); var mainBtn = UIFactory.CreateButton(groupObj, diff --git a/src/UI/Main/MainMenu.cs b/src/UI/Main/MainMenu.cs index 3f9c6b3..111d9a5 100644 --- a/src/UI/Main/MainMenu.cs +++ b/src/UI/Main/MainMenu.cs @@ -180,7 +180,7 @@ namespace UnityExplorer.UI.Main // Hide button ColorBlock colorBlock = new ColorBlock(); - RuntimeProvider.Instance.SetColorBlock(colorBlock, new Color(65f / 255f, 23f / 255f, 23f / 255f), + colorBlock = RuntimeProvider.Instance.SetColorBlock(colorBlock, new Color(65f / 255f, 23f / 255f, 23f / 255f), new Color(35f / 255f, 10f / 255f, 10f / 255f), new Color(156f / 255f, 0f, 0f)); var hideButton = UIFactory.CreateButton(titleBar, diff --git a/src/UI/UIManager.cs b/src/UI/UIManager.cs index a63c67f..0f76eed 100644 --- a/src/UI/UIManager.cs +++ b/src/UI/UIManager.cs @@ -53,8 +53,7 @@ namespace UnityExplorer.UI // Force refresh of anchors etc Canvas.ForceUpdateCanvases(); - if (!ConfigManager.Hide_On_Startup.Value) - ShowMenu = true; + ShowMenu = !ConfigManager.Hide_On_Startup.Value; ExplorerCore.Log("UI initialized."); }