Compare commits

..

14 Commits

Author SHA1 Message Date
46f35129c5 3.2.10
* The following preferences are now persistent between sessions: Active Menu Page, Scene Explorer Hide State, Debug Console Hide State
* The "Resize Cursor" is now just a `↔` Text label instead of a sprite.
* Added support for Unity 5.2+ games (previously was only supporting 5.6)
2021-03-26 19:49:53 +11:00
604c499822 Add Reset button to C# Console 2021-03-26 07:31:30 +11:00
8964c48ba0 Move melon attributes to ExplorerMelonMod.cs 2021-03-26 06:38:59 +11:00
e85a3e0f1e Merge bepinex/melonloader unhollowed libs 2021-03-26 06:04:44 +11:00
c658d393f5 Update README.md 2021-03-26 05:59:17 +11:00
9a45e29e02 Update README.md 2021-03-26 05:53:03 +11:00
418ece55e3 Improve UI inspect-under-mouse 2021-03-26 05:43:53 +11:00
bf455893e7 Include all references in lib folder 2021-03-26 05:40:12 +11:00
6d9cb8205a Update README.md 2021-03-25 18:48:40 +11:00
0f431e997b Update README.md 2021-03-25 18:47:52 +11:00
2107df70ad Improvements to CS Console
* Errors are now logged properly.
* Can now define classes, methods, etc - no longer has to be an expression body.
* Added `StartCoroutine(IEnumerator routine)` helper method to easily run a Coroutine
* Disabling suggestions now properly stops Explorer trying to update suggestion cache instead of just not showing them. In the rare cases that suggestions cause a crash, disabling them will now prevent those crashes.
* Various other misc improvements behind the scenes
2021-03-25 18:39:35 +11:00
a9fbea7c96 (C# Console) Only update autocomplete and indent if they are enabled 2021-03-24 17:14:13 +11:00
77878ddd94 Use reflection for adding Unity log callback to avoid unstripping errors 2021-03-24 17:13:43 +11:00
594abc47f8 Move RuntimeProvider.Init to after config is loaded 2021-03-24 17:13:26 +11:00
57 changed files with 1291 additions and 838 deletions

View File

@ -18,7 +18,7 @@
- [How to install](#how-to-install) - [How to install](#how-to-install)
- [Mod Config](#mod-config) - [Mod Config](#mod-config)
- [Building](#building) - [Building](#building)
- [Credits](#credits) - [Acknowledgments](#acknowledgments)
## Releases ## Releases
@ -46,6 +46,32 @@
* <b>C# Console</b>: Interactive console for evaluating C# methods on the fly, with some basic helpers. * <b>C# Console</b>: Interactive console for evaluating C# methods on the fly, with some basic helpers.
* <b>Inspect-under-mouse</b>: Hover over an object with a collider and inspect it by clicking on it. There's also a UI mode to inspect UI objects. * <b>Inspect-under-mouse</b>: Hover over an object with a collider and inspect it by clicking on it. There's also a UI mode to inspect UI objects.
### C# Console Tips
The C# Console can be used to define temporary classes and methods, or it can be used to evaluate an expression, but you cannot do both at the same time.
For example, you could run this code to define a temporary class (it will be visible within the console until you run `Reset();`).
```csharp
public class MyClass
{
public static void Method()
{
UnityExplorer.ExplorerCore.Log("hello");
}
}
```
You could then delete or comment out the class and run the following expression to run that method:
```csharp
MyClass.Method();
```
However, you cannot define a class and run it both at the same time. You must either define class(es) and run that, or define an expression and run that.
You can also make use of the helper methods in the console to simplify some tasks, which you can see listed when the console has nothing entered for input. These methods are **not** accessible within any temporary classes you define, they can only be used in the expression context.
## How to install ## How to install
### BepInEx ### BepInEx
@ -110,27 +136,21 @@ You can change the settings via the "Options" page of the main menu, or directly
## Building ## Building
If you'd like to build this yourself, all you need to do is download this repository and build from Visual Studio. If you want to build for BepInEx or MelonLoader IL2CPP then you will need to install the mod loader for a game and set the directory in the `csproj` file. If you'd like to build this yourself, all you need to do is download this repository and build from Visual Studio.
For IL2CPP:
1. Install BepInEx or MelonLoader for your game.
2. Open the `src\UnityExplorer.csproj` file in a text editor.
3. Set `BIECppGameFolder` (for BepInEx) and/or `MLCppGameFolder` (for MelonLoader) so the project can locate the necessary references.
4. For Standalone builds, you can either install BepInEx for the game to build, or just change the .csproj file and set the Unhollower reference manually.
For all builds:
1. Open the `src\UnityExplorer.sln` project. 1. Open the `src\UnityExplorer.sln` project.
2. Select `Solution 'UnityExplorer' (1 of 1 project)` in the Solution Explorer panel, and set the <b>Active config</b> property to the version you want to build, then build it. 2. Select `Solution 'UnityExplorer' (1 of 1 project)` in the Solution Explorer panel, and set the <b>Active config</b> property to the version you want to build, then build it. Alternatively, use "Batch Build" and select all releases.
3. The DLLs are built to the `Release\` folder in the root of the repository. 3. The DLLs are built to the `Release\` folder in the root of the repository.
4. If ILRepack fails or is missing, use the NuGet package manager to re-install `ILRepack.Lib.MSBuild.Task`, then re-build.
## Credits The references are all inside the `lib\` folder, if you need to change them for some reason then you can replace them there.
Written by Sinai. ## Acknowledgments
### Licensing * [ManlyMarco](https://github.com/ManlyMarco) for [Runtime Unity Editor](https://github.com/ManlyMarco/RuntimeUnityEditor) (GPL), snippets from the REPL Console were used for UnityExplorer's C# Console.
* [denikson](https://github.com/denikson) (aka Horse) for [mcs-unity](https://github.com/denikson/mcs-unity) (MIT), used as the `Mono.CSharp` reference for the C# Console.
* [HerpDerpenstine](https://github.com/HerpDerpinstine) for [MelonCoroutines](https://github.com/LavaGang/MelonLoader/blob/master/MelonLoader.Support.Il2Cpp/MelonCoroutines.cs) (Apache), they were included for standalone Il2CPP coroutine support.
* [InGameCodeEditor](https://assetstore.unity.com/packages/tools/gui/ingame-code-editor-144254) (Apache) was used as the base for the syntax highlighting for UnityExplorer's C# console (`UnityExplorer.UI.Main.CSConsole.Lexer`).
This project uses code from: ### Disclaimer
* (GPL) [ManlyMarco](https://github.com/ManlyMarco)'s [Runtime Unity Editor](https://github.com/ManlyMarco/RuntimeUnityEditor), which I used for some aspects of the C# Console and Auto-Complete features. The snippets I used are indicated with a comment.
* (MIT) [denikson](https://github.com/denikson) (aka Horse)'s [mcs-unity](https://github.com/denikson/mcs-unity). I commented out the `SkipVisibilityExt` constructor since it was causing an exception with the Hook it attempted in IL2CPP. UnityExplorer is in no way associated with Unity Technologies. "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere.
* (Apache) [InGameCodeEditor](https://assetstore.unity.com/packages/tools/gui/ingame-code-editor-144254) was used as the base for the syntax highlighting for UnityExplorer's C# console, although it has been heavily rewritten and optimized. Used classes are in the `UnityExplorer.UI.Main.CSConsole.Lexer` namespace.

BIN
lib/UnhollowerBaseLib.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,29 @@
#if MONO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace UnityExplorer.Core.CSharp
{
public class DummyBehaviour : MonoBehaviour
{
public static DummyBehaviour Instance;
public static void Setup()
{
var obj = new GameObject("Explorer_DummyBehaviour");
DontDestroyOnLoad(obj);
obj.hideFlags |= HideFlags.HideAndDontSave;
obj.AddComponent<DummyBehaviour>();
}
internal void Awake()
{
Instance = this;
}
}
}
#endif

View File

@ -15,11 +15,12 @@ namespace UnityExplorer.Core.CSharp
"mscorlib", "System.Core", "System", "System.Xml" "mscorlib", "System.Core", "System", "System.Xml"
}; };
private readonly TextWriter tw; internal static TextWriter _textWriter;
internal static StreamReportPrinter _reportPrinter;
public ScriptEvaluator(TextWriter tw) : base(BuildContext(tw)) public ScriptEvaluator(TextWriter tw) : base(BuildContext(tw))
{ {
this.tw = tw; _textWriter = tw;
ImportAppdomainAssemblies(ReferenceAssembly); ImportAppdomainAssemblies(ReferenceAssembly);
AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoad; AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoad;
@ -28,23 +29,22 @@ namespace UnityExplorer.Core.CSharp
public void Dispose() public void Dispose()
{ {
AppDomain.CurrentDomain.AssemblyLoad -= OnAssemblyLoad; AppDomain.CurrentDomain.AssemblyLoad -= OnAssemblyLoad;
tw.Dispose(); _textWriter.Dispose();
} }
private void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args) private void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)
{ {
string name = args.LoadedAssembly.GetName().Name; string name = args.LoadedAssembly.GetName().Name;
if (StdLib.Contains(name)) if (StdLib.Contains(name))
{
return; return;
}
ReferenceAssembly(args.LoadedAssembly); ReferenceAssembly(args.LoadedAssembly);
} }
private static CompilerContext BuildContext(TextWriter tw) private static CompilerContext BuildContext(TextWriter tw)
{ {
var reporter = new StreamReportPrinter(tw); _reportPrinter = new StreamReportPrinter(tw);
var settings = new CompilerSettings var settings = new CompilerSettings
{ {
@ -56,7 +56,7 @@ namespace UnityExplorer.Core.CSharp
EnhancedWarnings = false EnhancedWarnings = false
}; };
return new CompilerContext(settings, reporter); return new CompilerContext(settings, _reportPrinter);
} }
private static void ImportAppdomainAssemblies(Action<Assembly> import) private static void ImportAppdomainAssemblies(Action<Assembly> import)

View File

@ -4,6 +4,11 @@ using UnityExplorer.UI;
using UnityExplorer.UI.Main; using UnityExplorer.UI.Main;
using UnityExplorer.Core.Inspectors; using UnityExplorer.Core.Inspectors;
using UnityExplorer.UI.Main.CSConsole; using UnityExplorer.UI.Main.CSConsole;
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using UnityExplorer.Core.Runtime;
namespace UnityExplorer.Core.CSharp namespace UnityExplorer.Core.CSharp
{ {
@ -14,6 +19,11 @@ namespace UnityExplorer.Core.CSharp
ExplorerCore.Log(message); ExplorerCore.Log(message);
} }
public static void StartCoroutine(IEnumerator ienumerator)
{
RuntimeProvider.Instance.StartConsoleCoroutine(ienumerator);
}
public static void AddUsing(string directive) public static void AddUsing(string directive)
{ {
CSharpConsole.Instance.AddUsing(directive); CSharpConsole.Instance.AddUsing(directive);
@ -21,7 +31,7 @@ namespace UnityExplorer.Core.CSharp
public static void GetUsing() public static void GetUsing()
{ {
ExplorerCore.Log(CSharpConsole.Instance.m_evaluator.GetUsing()); ExplorerCore.Log(CSharpConsole.Instance.Evaluator.GetUsing());
} }
public static void Reset() public static void Reset()

View File

@ -5,6 +5,8 @@ using IniParser;
using IniParser.Parser; using IniParser.Parser;
using UnityExplorer.UI; using UnityExplorer.UI;
using System.Globalization; using System.Globalization;
using UnityExplorer.Core.Inspectors;
using UnityExplorer.UI.Main;
namespace UnityExplorer.Core.Config namespace UnityExplorer.Core.Config
{ {
@ -17,13 +19,6 @@ namespace UnityExplorer.Core.Config
internal static CultureInfo _enCulture = new CultureInfo("en-US"); internal static CultureInfo _enCulture = new CultureInfo("en-US");
static ExplorerConfig()
{
_parser.Configuration.CommentString = "#";
PanelDragger.OnFinishResize += PanelDragger_OnFinishResize;
}
// Actual configs // Actual configs
public KeyCode Main_Menu_Toggle = KeyCode.F7; public KeyCode Main_Menu_Toggle = KeyCode.F7;
public bool Force_Unlock_Mouse = true; public bool Force_Unlock_Mouse = true;
@ -32,6 +27,9 @@ namespace UnityExplorer.Core.Config
public bool Log_Unity_Debug = false; public bool Log_Unity_Debug = false;
public bool Hide_On_Startup = false; public bool Hide_On_Startup = false;
public string Window_Anchors = DEFAULT_WINDOW_ANCHORS; public string Window_Anchors = DEFAULT_WINDOW_ANCHORS;
public int Active_Tab = 0;
public bool DebugConsole_Hidden = false;
public bool SceneExplorer_Hidden = false;
private const string DEFAULT_WINDOW_ANCHORS = "0.25,0.10,0.78,0.95"; private const string DEFAULT_WINDOW_ANCHORS = "0.25,0.10,0.78,0.95";
@ -45,6 +43,12 @@ namespace UnityExplorer.Core.Config
public static void OnLoad() public static void OnLoad()
{ {
Instance = new ExplorerConfig(); Instance = new ExplorerConfig();
_parser.Configuration.CommentString = "#";
PanelDragger.OnFinishResize += PanelDragger_OnFinishResize;
SceneExplorer.OnToggleShow += SceneExplorer_OnToggleShow;
DebugConsole.OnToggleShow += DebugConsole_OnToggleShow;
MainMenu.OnActiveTabChanged += MainMenu_OnActiveTabChanged;
if (LoadSettings()) if (LoadSettings())
return; return;
@ -86,6 +90,15 @@ namespace UnityExplorer.Core.Config
case nameof(Window_Anchors): case nameof(Window_Anchors):
Instance.Window_Anchors = config.Value; Instance.Window_Anchors = config.Value;
break; break;
case nameof(Active_Tab):
Instance.Active_Tab = int.Parse(config.Value);
break;
case nameof(DebugConsole_Hidden):
Instance.DebugConsole_Hidden = bool.Parse(config.Value);
break;
case nameof(SceneExplorer_Hidden):
Instance.SceneExplorer_Hidden = bool.Parse(config.Value);
break;
} }
} }
@ -106,6 +119,9 @@ namespace UnityExplorer.Core.Config
sec.AddKey(nameof(Default_Output_Path), Instance.Default_Output_Path); sec.AddKey(nameof(Default_Output_Path), Instance.Default_Output_Path);
sec.AddKey(nameof(Hide_On_Startup), Instance.Hide_On_Startup.ToString()); sec.AddKey(nameof(Hide_On_Startup), Instance.Hide_On_Startup.ToString());
sec.AddKey(nameof(Window_Anchors), GetWindowAnchorsString()); sec.AddKey(nameof(Window_Anchors), GetWindowAnchorsString());
sec.AddKey(nameof(Active_Tab), Instance.Active_Tab.ToString());
sec.AddKey(nameof(DebugConsole_Hidden), Instance.DebugConsole_Hidden.ToString());
sec.AddKey(nameof(SceneExplorer_Hidden), Instance.SceneExplorer_Hidden.ToString());
if (!Directory.Exists(ExplorerCore.Loader.ConfigFolder)) if (!Directory.Exists(ExplorerCore.Loader.ConfigFolder))
Directory.CreateDirectory(ExplorerCore.Loader.ConfigFolder); Directory.CreateDirectory(ExplorerCore.Loader.ConfigFolder);
@ -113,6 +129,24 @@ namespace UnityExplorer.Core.Config
File.WriteAllText(INI_PATH, data.ToString()); File.WriteAllText(INI_PATH, data.ToString());
} }
private static void SceneExplorer_OnToggleShow()
{
Instance.SceneExplorer_Hidden = SceneExplorer.UI.Hiding;
SaveSettings();
}
private static void DebugConsole_OnToggleShow()
{
Instance.DebugConsole_Hidden = DebugConsole.Hiding;
SaveSettings();
}
private static void MainMenu_OnActiveTabChanged(int page)
{
Instance.Active_Tab = page;
SaveSettings();
}
// ============ Window Anchors specific stuff ============== // // ============ Window Anchors specific stuff ============== //
private static void PanelDragger_OnFinishResize() private static void PanelDragger_OnFinishResize()

View File

@ -37,28 +37,40 @@ namespace UnityExplorer.Core.Inspectors
UI = new MouseInspectorUI(); UI = new MouseInspectorUI();
} }
public static void StartInspect() private static readonly List<Graphic> _wasDisabledGraphics = new List<Graphic>();
private static readonly List<CanvasGroup> _wasDisabledCanvasGroups = new List<CanvasGroup>();
private static readonly List<GameObject> _objectsAddedCastersTo = new List<GameObject>();
public static void StartInspect(MouseInspectMode mode)
{ {
Mode = mode;
Enabled = true; Enabled = true;
MainMenu.Instance.MainPanel.SetActive(false); MainMenu.Instance.MainPanel.SetActive(false);
UI.s_UIContent.SetActive(true); UI.s_UIContent.SetActive(true);
// recache Graphic Raycasters each time we start if (mode == MouseInspectMode.UI)
var casters = RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(GraphicRaycaster));
m_gCasters = new GraphicRaycaster[casters.Length];
for (int i = 0; i < casters.Length; i++)
{ {
m_gCasters[i] = casters[i].Cast(typeof(GraphicRaycaster)) as GraphicRaycaster; SetupUIRaycast();
} }
} }
internal static void ClearHitData()
{
s_lastHit = null;
UI.s_objNameLabel.text = "No hits...";
UI.s_objPathLabel.text = "";
}
public static void StopInspect() public static void StopInspect()
{ {
Enabled = false; Enabled = false;
MainMenu.Instance.MainPanel.SetActive(true); MainMenu.Instance.MainPanel.SetActive(true);
UI.s_UIContent.SetActive(false); UI.s_UIContent.SetActive(false);
if (Mode == MouseInspectMode.UI)
StopUIInspect();
ClearHitData(); ClearHitData();
} }
@ -91,6 +103,18 @@ namespace UnityExplorer.Core.Inspectors
} }
} }
internal static void UpdatePosition(Vector2 mousePos)
{
s_lastMousePos = mousePos;
var inversePos = UIManager.CanvasRoot.transform.InverseTransformPoint(mousePos);
UI.s_mousePosLabel.text = $"<color=grey>Mouse Position:</color> {mousePos.ToString()}";
float yFix = mousePos.y < 120 ? 80 : -80;
UI.s_UIContent.transform.localPosition = new Vector3(inversePos.x, inversePos.y + yFix, 0);
}
internal static void OnHitGameObject(GameObject obj) internal static void OnHitGameObject(GameObject obj)
{ {
if (obj != s_lastHit) if (obj != s_lastHit)
@ -107,6 +131,8 @@ namespace UnityExplorer.Core.Inspectors
} }
} }
// Collider raycasting
internal static void RaycastWorld(Vector2 mousePos) internal static void RaycastWorld(Vector2 mousePos)
{ {
var ray = UnityHelper.MainCamera.ScreenPointToRay(mousePos); var ray = UnityHelper.MainCamera.ScreenPointToRay(mousePos);
@ -124,6 +150,54 @@ namespace UnityExplorer.Core.Inspectors
} }
} }
// UI Graphic raycasting
private static void SetupUIRaycast()
{
foreach (var obj in RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(Canvas)))
{
var canvas = obj.Cast(typeof(Canvas)) as Canvas;
if (!canvas || !canvas.enabled || !canvas.gameObject.activeInHierarchy)
continue;
if (!canvas.GetComponent<GraphicRaycaster>())
{
canvas.gameObject.AddComponent<GraphicRaycaster>();
//ExplorerCore.Log("Added raycaster to " + canvas.name);
_objectsAddedCastersTo.Add(canvas.gameObject);
}
}
// recache Graphic Raycasters each time we start
var casters = RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(GraphicRaycaster));
m_gCasters = new GraphicRaycaster[casters.Length];
for (int i = 0; i < casters.Length; i++)
{
m_gCasters[i] = casters[i].Cast(typeof(GraphicRaycaster)) as GraphicRaycaster;
}
// enable raycastTarget on Graphics
foreach (var obj in RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(Graphic)))
{
var graphic = obj.Cast(typeof(Graphic)) as Graphic;
if (!graphic || !graphic.enabled || graphic.raycastTarget || !graphic.gameObject.activeInHierarchy)
continue;
graphic.raycastTarget = true;
//ExplorerCore.Log("Enabled raycastTarget on " + graphic.name);
_wasDisabledGraphics.Add(graphic);
}
// enable blocksRaycasts on CanvasGroups
foreach (var obj in RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(CanvasGroup)))
{
var canvas = obj.Cast(typeof(CanvasGroup)) as CanvasGroup;
if (!canvas || !canvas.gameObject.activeInHierarchy || canvas.blocksRaycasts)
continue;
canvas.blocksRaycasts = true;
//ExplorerCore.Log("Enabled raycasts on " + canvas.name);
_wasDisabledCanvasGroups.Add(canvas);
}
}
internal static void RaycastUI(Vector2 mousePos) internal static void RaycastUI(Vector2 mousePos)
{ {
var ped = new PointerEventData(null) var ped = new PointerEventData(null)
@ -136,6 +210,11 @@ namespace UnityExplorer.Core.Inspectors
#else #else
var list = new Il2CppSystem.Collections.Generic.List<RaycastResult>(); var list = new Il2CppSystem.Collections.Generic.List<RaycastResult>();
#endif #endif
//ExplorerCore.Log("~~~~~~~~~ begin raycast ~~~~~~~~");
GameObject hitObject = null;
int highestLayer = int.MinValue;
int highestOrder = int.MinValue;
int highestDepth = int.MinValue;
foreach (var gr in m_gCasters) foreach (var gr in m_gCasters)
{ {
gr.Raycast(ped, list); gr.Raycast(ped, list);
@ -144,14 +223,40 @@ namespace UnityExplorer.Core.Inspectors
{ {
foreach (var hit in list) foreach (var hit in list)
{ {
if (hit.gameObject) if (!hit.gameObject)
continue;
if (hit.gameObject.GetComponent<CanvasGroup>() is CanvasGroup group && group.alpha == 0)
continue;
if (hit.gameObject.GetComponent<Graphic>() is Graphic graphic && graphic.color.a == 0f)
continue;
//ExplorerCore.Log("Hit: " + hit.gameObject.name + ", depth: " + hit.depth + ", layer: " + hit.sortingLayer + ", order: " + hit.sortingOrder);
if (hit.sortingLayer < highestLayer)
continue;
if (hit.sortingLayer > highestLayer)
{ {
var obj = hit.gameObject; highestLayer = hit.sortingLayer;
highestOrder = int.MinValue;
OnHitGameObject(obj);
break;
} }
if (hit.depth < highestDepth)
continue;
if (hit.depth > highestDepth)
{
highestDepth = hit.depth;
highestOrder = int.MinValue;
}
if (hit.sortingOrder <= highestOrder)
continue;
highestOrder = hit.sortingOrder;
hitObject = hit.gameObject;
} }
} }
else else
@ -160,25 +265,30 @@ namespace UnityExplorer.Core.Inspectors
ClearHitData(); ClearHitData();
} }
} }
if (hitObject)
OnHitGameObject(hitObject);
//ExplorerCore.Log("~~~~~~~~~ end raycast ~~~~~~~~");
} }
internal static void UpdatePosition(Vector2 mousePos) private static void StopUIInspect()
{ {
s_lastMousePos = mousePos; foreach (var obj in _objectsAddedCastersTo)
var inversePos = UIManager.CanvasRoot.transform.InverseTransformPoint(mousePos);
UI.s_mousePosLabel.text = $"<color=grey>Mouse Position:</color> {mousePos.ToString()}";
float yFix = mousePos.y < 120 ? 80 : -80;
UI.s_UIContent.transform.localPosition = new Vector3(inversePos.x, inversePos.y + yFix, 0);
}
internal static void ClearHitData()
{ {
s_lastHit = null; if (obj.GetComponent<GraphicRaycaster>() is GraphicRaycaster raycaster)
UI.s_objNameLabel.text = "No hits..."; GameObject.Destroy(raycaster);
UI.s_objPathLabel.text = ""; }
foreach (var graphic in _wasDisabledGraphics)
graphic.raycastTarget = false;
foreach (var canvas in _wasDisabledCanvasGroups)
canvas.blocksRaycasts = false;
_objectsAddedCastersTo.Clear();
_wasDisabledCanvasGroups.Clear();
_wasDisabledGraphics.Clear();
} }
} }
} }

View File

@ -224,8 +224,8 @@ namespace UnityExplorer.Core.Inspectors.Reflection
var topGroup = topGroupObj.GetComponent<HorizontalLayoutGroup>(); var topGroup = topGroupObj.GetComponent<HorizontalLayoutGroup>();
topGroup.childForceExpandHeight = false; topGroup.childForceExpandHeight = false;
topGroup.childForceExpandWidth = false; topGroup.childForceExpandWidth = false;
topGroup.childControlHeight = true; topGroup.SetChildControlHeight(true);
topGroup.childControlWidth = true; topGroup.SetChildControlWidth(true);
topGroup.spacing = 10; topGroup.spacing = 10;
topGroup.padding.left = 3; topGroup.padding.left = 3;
topGroup.padding.right = 3; topGroup.padding.right = 3;
@ -243,8 +243,8 @@ namespace UnityExplorer.Core.Inspectors.Reflection
var leftGroup = m_leftGroup.GetComponent<HorizontalLayoutGroup>(); var leftGroup = m_leftGroup.GetComponent<HorizontalLayoutGroup>();
leftGroup.childForceExpandHeight = true; leftGroup.childForceExpandHeight = true;
leftGroup.childForceExpandWidth = false; leftGroup.childForceExpandWidth = false;
leftGroup.childControlHeight = true; leftGroup.SetChildControlHeight(true);
leftGroup.childControlWidth = true; leftGroup.SetChildControlWidth(true);
leftGroup.spacing = 4; leftGroup.spacing = 4;
// member label // member label
@ -278,8 +278,8 @@ namespace UnityExplorer.Core.Inspectors.Reflection
var rightGroup = m_rightGroup.GetComponent<VerticalLayoutGroup>(); var rightGroup = m_rightGroup.GetComponent<VerticalLayoutGroup>();
rightGroup.childForceExpandHeight = true; rightGroup.childForceExpandHeight = true;
rightGroup.childForceExpandWidth = false; rightGroup.childForceExpandWidth = false;
rightGroup.childControlHeight = true; rightGroup.SetChildControlHeight(true);
rightGroup.childControlWidth = true; rightGroup.SetChildControlWidth(true);
rightGroup.spacing = 2; rightGroup.spacing = 2;
rightGroup.padding.top = 4; rightGroup.padding.top = 4;
rightGroup.padding.bottom = 2; rightGroup.padding.bottom = 2;

View File

@ -92,9 +92,9 @@ namespace UnityExplorer.Core.Inspectors.Reflection
m_mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25); m_mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25);
var mainGroup = m_mainContent.GetComponent<VerticalLayoutGroup>(); var mainGroup = m_mainContent.GetComponent<VerticalLayoutGroup>();
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
var mainLayout = m_mainContent.AddComponent<LayoutElement>(); var mainLayout = m_mainContent.AddComponent<LayoutElement>();
mainLayout.minHeight = 25; mainLayout.minHeight = 25;
mainLayout.flexibleHeight = 9999; mainLayout.flexibleHeight = 9999;

View File

@ -296,7 +296,7 @@ namespace UnityExplorer.Core.Inspectors.Reflection
var scrollGroup = m_listContent.GetComponent<VerticalLayoutGroup>(); var scrollGroup = m_listContent.GetComponent<VerticalLayoutGroup>();
scrollGroup.childForceExpandHeight = true; scrollGroup.childForceExpandHeight = true;
scrollGroup.childControlHeight = true; scrollGroup.SetChildControlHeight(true);
scrollGroup.spacing = 2; scrollGroup.spacing = 2;
scrollGroup.padding.top = 5; scrollGroup.padding.top = 5;
scrollGroup.padding.left = 5; scrollGroup.padding.left = 5;

View File

@ -270,7 +270,7 @@ namespace UnityExplorer.Core.Inspectors.Reflection
var scrollGroup = m_listContent.GetComponent<VerticalLayoutGroup>(); var scrollGroup = m_listContent.GetComponent<VerticalLayoutGroup>();
scrollGroup.childForceExpandHeight = true; scrollGroup.childForceExpandHeight = true;
scrollGroup.childControlHeight = true; scrollGroup.SetChildControlHeight(true);
scrollGroup.spacing = 2; scrollGroup.spacing = 2;
scrollGroup.padding.top = 5; scrollGroup.padding.top = 5;
scrollGroup.padding.left = 5; scrollGroup.padding.left = 5;

View File

@ -98,8 +98,8 @@ namespace UnityExplorer.Core.Inspectors.Reflection
var group = groupObj.GetComponent<VerticalLayoutGroup>(); var group = groupObj.GetComponent<VerticalLayoutGroup>();
group.childForceExpandHeight = true; group.childForceExpandHeight = true;
group.childForceExpandWidth = false; group.childForceExpandWidth = false;
group.childControlHeight = true; group.SetChildControlHeight(true);
group.childControlWidth = true; group.SetChildControlWidth(true);
group.padding.top = 3; group.padding.top = 3;
group.padding.left = 3; group.padding.left = 3;
group.padding.right = 3; group.padding.right = 3;

View File

@ -155,9 +155,9 @@ namespace UnityExplorer.Core.Inspectors.Reflection
hiddenLayout.flexibleWidth = 9000; hiddenLayout.flexibleWidth = 9000;
var hiddenGroup = m_hiddenObj.AddComponent<HorizontalLayoutGroup>(); var hiddenGroup = m_hiddenObj.AddComponent<HorizontalLayoutGroup>();
hiddenGroup.childForceExpandWidth = true; hiddenGroup.childForceExpandWidth = true;
hiddenGroup.childControlWidth = true; hiddenGroup.SetChildControlWidth(true);
hiddenGroup.childForceExpandHeight = true; hiddenGroup.childForceExpandHeight = true;
hiddenGroup.childControlHeight = true; hiddenGroup.SetChildControlHeight(true);
var inputObj = UIFactory.CreateInputField(m_hiddenObj, 14, 3); var inputObj = UIFactory.CreateInputField(m_hiddenObj, 14, 3);
var inputLayout = inputObj.AddComponent<LayoutElement>(); var inputLayout = inputObj.AddComponent<LayoutElement>();

View File

@ -308,9 +308,9 @@ namespace UnityExplorer.Core.Inspectors.Reflection
mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25); mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25);
var mainGroup = m_valueContent.GetComponent<HorizontalLayoutGroup>(); var mainGroup = m_valueContent.GetComponent<HorizontalLayoutGroup>();
mainGroup.childForceExpandWidth = false; mainGroup.childForceExpandWidth = false;
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = false; mainGroup.childForceExpandHeight = false;
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.spacing = 4; mainGroup.spacing = 4;
mainGroup.childAlignment = TextAnchor.UpperLeft; mainGroup.childAlignment = TextAnchor.UpperLeft;
var mainLayout = m_valueContent.AddComponent<LayoutElement>(); var mainLayout = m_valueContent.AddComponent<LayoutElement>();

View File

@ -0,0 +1,156 @@
#if CPP
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnhollowerBaseLib;
using UnityEngine;
// CREDIT HerpDerpenstine
// https://github.com/LavaGang/MelonLoader/blob/master/MelonLoader.Support.Il2Cpp/MelonCoroutines.cs
namespace UnityExplorer.Core.Runtime.Il2Cpp
{
public static class Il2CppCoroutine
{
private struct CoroTuple
{
public object WaitCondition;
public IEnumerator Coroutine;
}
private static readonly List<CoroTuple> ourCoroutinesStore = new List<CoroTuple>();
private static readonly List<IEnumerator> ourNextFrameCoroutines = new List<IEnumerator>();
private static readonly List<IEnumerator> ourWaitForFixedUpdateCoroutines = new List<IEnumerator>();
private static readonly List<IEnumerator> ourWaitForEndOfFrameCoroutines = new List<IEnumerator>();
private static readonly List<IEnumerator> tempList = new List<IEnumerator>();
internal static object Start(IEnumerator routine)
{
if (routine != null) ProcessNextOfCoroutine(routine);
return routine;
}
internal static void Stop(IEnumerator enumerator)
{
if (ourNextFrameCoroutines.Contains(enumerator)) // the coroutine is running itself
ourNextFrameCoroutines.Remove(enumerator);
else
{
int coroTupleIndex = ourCoroutinesStore.FindIndex(c => c.Coroutine == enumerator);
if (coroTupleIndex != -1) // the coroutine is waiting for a subroutine
{
object waitCondition = ourCoroutinesStore[coroTupleIndex].WaitCondition;
if (waitCondition is IEnumerator waitEnumerator)
Stop(waitEnumerator);
ourCoroutinesStore.RemoveAt(coroTupleIndex);
}
}
}
private static void ProcessCoroList(List<IEnumerator> target)
{
if (target.Count == 0) return;
// use a temp list to make sure waits made during processing are not handled by same processing invocation
// additionally, a temp list reduces allocations compared to an array
tempList.AddRange(target);
target.Clear();
foreach (var enumerator in tempList) ProcessNextOfCoroutine(enumerator);
tempList.Clear();
}
internal static void Process()
{
for (var i = ourCoroutinesStore.Count - 1; i >= 0; i--)
{
var tuple = ourCoroutinesStore[i];
if (tuple.WaitCondition is WaitForSeconds waitForSeconds)
{
if ((waitForSeconds.m_Seconds -= Time.deltaTime) <= 0)
{
ourCoroutinesStore.RemoveAt(i);
ProcessNextOfCoroutine(tuple.Coroutine);
}
}
}
ProcessCoroList(ourNextFrameCoroutines);
}
internal static void ProcessWaitForFixedUpdate() => ProcessCoroList(ourWaitForFixedUpdateCoroutines);
internal static void ProcessWaitForEndOfFrame() => ProcessCoroList(ourWaitForEndOfFrameCoroutines);
private static void ProcessNextOfCoroutine(IEnumerator enumerator)
{
try
{
if (!enumerator.MoveNext()) // Run the next step of the coroutine. If it's done, restore the parent routine
{
var indices = ourCoroutinesStore.Select((it, idx) => (idx, it)).Where(it => it.it.WaitCondition == enumerator).Select(it => it.idx).ToList();
for (var i = indices.Count - 1; i >= 0; i--)
{
var index = indices[i];
ourNextFrameCoroutines.Add(ourCoroutinesStore[index].Coroutine);
ourCoroutinesStore.RemoveAt(index);
}
return;
}
}
catch (Exception e)
{
ExplorerCore.LogError(e.ToString());
Stop(FindOriginalCoro(enumerator)); // We want the entire coroutine hierachy to stop when an error happen
}
var next = enumerator.Current;
switch (next)
{
case null:
ourNextFrameCoroutines.Add(enumerator);
return;
case WaitForFixedUpdate _:
ourWaitForFixedUpdateCoroutines.Add(enumerator);
return;
case WaitForEndOfFrame _:
ourWaitForEndOfFrameCoroutines.Add(enumerator);
return;
case WaitForSeconds _:
break; // do nothing, this one is supported in Process
case Il2CppObjectBase il2CppObjectBase:
var nextAsEnumerator = il2CppObjectBase.TryCast<Il2CppSystem.Collections.IEnumerator>();
if (nextAsEnumerator != null) // il2cpp IEnumerator also handles CustomYieldInstruction
next = new Il2CppEnumeratorWrapper(nextAsEnumerator);
else
ExplorerCore.LogWarning($"Unknown coroutine yield object of type {il2CppObjectBase} for coroutine {enumerator}");
break;
}
ourCoroutinesStore.Add(new CoroTuple { WaitCondition = next, Coroutine = enumerator });
if (next is IEnumerator nextCoro)
ProcessNextOfCoroutine(nextCoro);
}
private static IEnumerator FindOriginalCoro(IEnumerator enumerator)
{
int index = ourCoroutinesStore.FindIndex(ct => ct.WaitCondition == enumerator);
if (index == -1)
return enumerator;
return FindOriginalCoro(ourCoroutinesStore[index].Coroutine);
}
private class Il2CppEnumeratorWrapper : IEnumerator
{
private readonly Il2CppSystem.Collections.IEnumerator il2cppEnumerator;
public Il2CppEnumeratorWrapper(Il2CppSystem.Collections.IEnumerator il2CppEnumerator) => il2cppEnumerator = il2CppEnumerator;
public bool MoveNext() => il2cppEnumerator.MoveNext();
public void Reset() => il2cppEnumerator.Reset();
public object Current => il2cppEnumerator.Current;
}
}
}
#endif

View File

@ -2,12 +2,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection;
using BF = System.Reflection.BindingFlags;
using System.Text; using System.Text;
using UnhollowerBaseLib; using UnhollowerBaseLib;
using UnhollowerRuntimeLib; using UnhollowerRuntimeLib;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using System.Collections;
using UnityEngine.UI;
namespace UnityExplorer.Core.Runtime.Il2Cpp namespace UnityExplorer.Core.Runtime.Il2Cpp
{ {
@ -21,14 +25,27 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
public override void SetupEvents() public override void SetupEvents()
{ {
Application.add_logMessageReceived( try
new Action<string, string, LogType>(ExplorerCore.Instance.OnUnityLog)); {
//Application.add_logMessageReceived(new Action<string, string, LogType>(ExplorerCore.Instance.OnUnityLog));
//SceneManager.add_sceneLoaded( var logType = ReflectionUtility.GetTypeByName("UnityEngine.Application+LogCallback");
// new Action<Scene, LoadSceneMode>(ExplorerCore.Instance.OnSceneLoaded1)); var castMethod = logType.GetMethod("op_Implicit", new[] { typeof(Action<string, string, LogType>) });
var addMethod = typeof(Application).GetMethod("add_logMessageReceived", BF.Static | BF.Public, null, new[] { logType }, null);
addMethod.Invoke(null, new[]
{
castMethod.Invoke(null, new[] { new Action<string, string, LogType>(ExplorerCore.Instance.OnUnityLog) })
});
}
catch
{
ExplorerCore.LogWarning("Exception setting up Unity log listener, make sure Unity libraries have been unstripped!");
}
}
//SceneManager.add_activeSceneChanged( public override void StartConsoleCoroutine(IEnumerator routine)
// new Action<Scene, Scene>(ExplorerCore.Instance.OnSceneLoaded2)); {
Il2CppCoroutine.Start(routine);
} }
internal delegate IntPtr d_LayerToName(int layer); internal delegate IntPtr d_LayerToName(int layer);
@ -91,7 +108,7 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
} }
} }
public static class UnityEventExtensions public static class Il2CppExtensions
{ {
public static void AddListener(this UnityEvent action, Action listener) public static void AddListener(this UnityEvent action, Action listener)
{ {
@ -102,6 +119,9 @@ public static class UnityEventExtensions
{ {
action.AddListener(listener); action.AddListener(listener);
} }
public static void SetChildControlHeight(this HorizontalOrVerticalLayoutGroup group, bool value) => group.childControlHeight = value;
public static void SetChildControlWidth(this HorizontalOrVerticalLayoutGroup group, bool value) => group.childControlWidth = value;
} }
#endif #endif

View File

@ -1,12 +1,15 @@
#if MONO #if MONO
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityExplorer.Core; using UnityExplorer.Core;
using UnityExplorer.Core.CSharp;
namespace UnityExplorer.Core.Runtime.Mono namespace UnityExplorer.Core.Runtime.Mono
{ {
@ -25,6 +28,11 @@ namespace UnityExplorer.Core.Runtime.Mono
//SceneManager.activeSceneChanged += ExplorerCore.Instance.OnSceneLoaded2; //SceneManager.activeSceneChanged += ExplorerCore.Instance.OnSceneLoaded2;
} }
public override void StartConsoleCoroutine(IEnumerator routine)
{
DummyBehaviour.Instance.StartCoroutine(routine);
}
public override string LayerToName(int layer) public override string LayerToName(int layer)
=> LayerMask.LayerToName(layer); => LayerMask.LayerToName(layer);
@ -50,4 +58,32 @@ namespace UnityExplorer.Core.Runtime.Mono
} }
} }
public static class MonoExtensions
{
public static void Clear(this StringBuilder sb)
{
sb.Remove(0, sb.Length);
}
private static PropertyInfo pi_childControlHeight;
public static void SetChildControlHeight(this HorizontalOrVerticalLayoutGroup group, bool value)
{
if (pi_childControlHeight == null)
pi_childControlHeight = group.GetType().GetProperty("childControlHeight");
pi_childControlHeight?.SetValue(group, value, null);
}
private static PropertyInfo pi_childControlWidth;
public static void SetChildControlWidth(this HorizontalOrVerticalLayoutGroup group, bool value)
{
if (pi_childControlWidth == null)
pi_childControlWidth = group.GetType().GetProperty("childControlWidth");
pi_childControlWidth?.SetValue(group, value, null);
}
}
#endif #endif

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -36,6 +37,8 @@ namespace UnityExplorer.Core.Runtime
public abstract void SetupEvents(); public abstract void SetupEvents();
public abstract void StartConsoleCoroutine(IEnumerator routine);
// Unity API handlers // Unity API handlers
public abstract string LayerToName(int layer); public abstract string LayerToName(int layer);

View File

@ -9,6 +9,7 @@ using UnityEngine.SceneManagement;
using UnityEngine.UI; using UnityEngine.UI;
using UnityExplorer.Core.Runtime; using UnityExplorer.Core.Runtime;
using UnityExplorer.UI.Main.Home; using UnityExplorer.UI.Main.Home;
using UnityExplorer.Core.Config;
namespace UnityExplorer.Core.Inspectors namespace UnityExplorer.Core.Inspectors
{ {
@ -58,14 +59,15 @@ namespace UnityExplorer.Core.Inspectors
public void Init() public void Init()
{ {
RefreshSceneSelector(); RefreshSceneSelector();
if (ExplorerConfig.Instance.SceneExplorer_Hidden)
UI.ToggleShow();
} }
public void Update() public void Update()
{ {
if (SceneExplorerUI.Hiding || Time.realtimeSinceStartup - m_timeOfLastSceneUpdate < UPDATE_INTERVAL) if (UI.Hiding || Time.realtimeSinceStartup - m_timeOfLastSceneUpdate < UPDATE_INTERVAL)
{
return; return;
}
RefreshSceneSelector(); RefreshSceneSelector();

View File

@ -17,7 +17,7 @@ namespace UnityExplorer
public class ExplorerCore public class ExplorerCore
{ {
public const string NAME = "UnityExplorer"; public const string NAME = "UnityExplorer";
public const string VERSION = "3.2.7"; public const string VERSION = "3.2.10";
public const string AUTHOR = "Sinai"; public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer"; public const string GUID = "com.sinai.unityexplorer";
@ -44,13 +44,13 @@ namespace UnityExplorer
Instance = this; Instance = this;
RuntimeProvider.Init();
if (!Directory.Exists(EXPLORER_FOLDER)) if (!Directory.Exists(EXPLORER_FOLDER))
Directory.CreateDirectory(EXPLORER_FOLDER); Directory.CreateDirectory(EXPLORER_FOLDER);
ExplorerConfig.OnLoad(); ExplorerConfig.OnLoad();
RuntimeProvider.Init();
InputManager.Init(); InputManager.Init();
CursorUnlocker.Init(); CursorUnlocker.Init();

View File

@ -2,6 +2,10 @@
using System; using System;
using System.IO; using System.IO;
using MelonLoader; using MelonLoader;
using UnityExplorer;
[assembly: MelonInfo(typeof(ExplorerMelonMod), ExplorerCore.NAME, ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
[assembly: MelonGame(null, null)]
namespace UnityExplorer namespace UnityExplorer
{ {

View File

@ -2,13 +2,6 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using UnityExplorer; using UnityExplorer;
#if ML
using MelonLoader;
[assembly: MelonInfo(typeof(ExplorerMelonMod), "UnityExplorer", ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
[assembly: MelonGame(null, null)]
#endif
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.

Binary file not shown.

View File

@ -205,7 +205,7 @@ namespace UnityExplorer.UI.Main.CSConsole
{ {
// Credit ManylMarco // Credit ManylMarco
CSharpConsole.AutoCompletes.Clear(); CSharpConsole.AutoCompletes.Clear();
string[] completions = CSharpConsole.Instance.m_evaluator.GetCompletions(input, out string prefix); string[] completions = CSharpConsole.Instance.Evaluator.GetCompletions(input, out string prefix);
if (completions != null) if (completions != null)
{ {
if (prefix == null) if (prefix == null)
@ -269,8 +269,8 @@ namespace UnityExplorer.UI.Main.CSConsole
mainRect.offsetMax = Vector2.zero; mainRect.offsetMax = Vector2.zero;
var mainGroup = content.GetComponent<VerticalLayoutGroup>(); var mainGroup = content.GetComponent<VerticalLayoutGroup>();
mainGroup.childControlHeight = false; mainGroup.SetChildControlHeight(false);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = false; mainGroup.childForceExpandHeight = false;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;

View File

@ -53,13 +53,8 @@ namespace UnityExplorer.UI.Main.CSConsole
"else", "equals", "false", "finally", "float", "for", "foreach", "from", "global", "goto", "group", "else", "equals", "false", "finally", "float", "for", "foreach", "from", "global", "goto", "group",
"if", "in", "int", "into", "is", "join", "let", "lock", "long", "new", "null", "object", "on", "orderby", "out", "if", "in", "int", "into", "is", "join", "let", "lock", "long", "new", "null", "object", "on", "orderby", "out",
"ref", "remove", "return", "sbyte", "select", "short", "sizeof", "stackalloc", "string", "ref", "remove", "return", "sbyte", "select", "short", "sizeof", "stackalloc", "string",
"switch", "throw", "true", "try", "typeof", "uint", "ulong", "ushort", "var", "where", "while", "yield" } "switch", "throw", "true", "try", "typeof", "uint", "ulong", "ushort", "var", "where", "while", "yield",
}; "abstract", "async", "base", "class", "delegate", "enum", "explicit", "extern", "fixed", "get",
public static KeywordMatch invalidKeywordMatcher = new KeywordMatch()
{
highlightColor = new Color(0.95f, 0.10f, 0.10f, 1.0f),
Keywords = new[] { "abstract", "async", "base", "class", "delegate", "enum", "explicit", "extern", "fixed", "get",
"implicit", "interface", "internal", "namespace", "operator", "override", "params", "private", "protected", "public", "implicit", "interface", "internal", "namespace", "operator", "override", "params", "private", "protected", "public",
"using", "partial", "readonly", "sealed", "set", "static", "struct", "this", "unchecked", "unsafe", "value", "virtual", "volatile", "void"} "using", "partial", "readonly", "sealed", "set", "static", "struct", "this", "unchecked", "unsafe", "value", "virtual", "volatile", "void"}
}; };
@ -78,7 +73,6 @@ namespace UnityExplorer.UI.Main.CSConsole
numberMatcher, numberMatcher,
stringMatcher, stringMatcher,
validKeywordMatcher, validKeywordMatcher,
invalidKeywordMatcher,
}; };
foreach (Matcher lexer in matchers) foreach (Matcher lexer in matchers)

View File

@ -12,6 +12,10 @@ using UnityEngine.UI;
using UnityExplorer.UI.Reusable; using UnityExplorer.UI.Reusable;
using UnityExplorer.UI.Main.CSConsole; using UnityExplorer.UI.Main.CSConsole;
using UnityExplorer.Core; using UnityExplorer.Core;
using UnityExplorer.Core.Unity;
#if CPP
using UnityExplorer.Core.Runtime.Il2Cpp;
#endif
namespace UnityExplorer.UI.Main.CSConsole namespace UnityExplorer.UI.Main.CSConsole
{ {
@ -21,8 +25,8 @@ namespace UnityExplorer.UI.Main.CSConsole
public static CSharpConsole Instance { get; private set; } public static CSharpConsole Instance { get; private set; }
//public UI.CSConsole.CSharpConsole m_codeEditor; public ScriptEvaluator Evaluator;
public ScriptEvaluator m_evaluator; internal StringBuilder m_evalLogBuilder;
public static List<string> UsingDirectives; public static List<string> UsingDirectives;
@ -49,14 +53,13 @@ namespace UnityExplorer.UI.Main.CSConsole
InitConsole(); InitConsole();
AutoCompleter.Init(); AutoCompleter.Init();
#if MONO
DummyBehaviour.Setup();
#endif
ResetConsole(); ResetConsole(false);
// Make sure compiler is supported on this platform // Make sure compiler is supported on this platform
m_evaluator.Compile(""); Evaluator.Compile("");
foreach (string use in DefaultUsing)
AddUsing(use);
return true; return true;
} }
@ -74,10 +77,32 @@ namespace UnityExplorer.UI.Main.CSConsole
} }
} }
public void ResetConsole(bool log = true)
{
if (Evaluator != null)
Evaluator.Dispose();
m_evalLogBuilder = new StringBuilder();
Evaluator = new ScriptEvaluator(new StringWriter(m_evalLogBuilder)) { InteractiveBaseClass = typeof(ScriptInteraction) };
UsingDirectives = new List<string>();
foreach (string use in DefaultUsing)
AddUsing(use);
if (log)
ExplorerCore.Log($"C# Console reset. Using directives:\r\n{Evaluator.GetUsing()}");
}
public override void Update() public override void Update()
{ {
UpdateConsole(); UpdateConsole();
AutoCompleter.Update(); AutoCompleter.Update();
#if CPP
Il2CppCoroutine.Process();
#endif
} }
public void AddUsing(string asm) public void AddUsing(string asm)
@ -89,40 +114,34 @@ namespace UnityExplorer.UI.Main.CSConsole
} }
} }
public void Evaluate(string code, bool suppressWarning = false) public void Evaluate(string code, bool supressLog = false)
{
m_evaluator.Compile(code, out Mono.CSharp.CompiledMethod compiled);
if (compiled == null)
{
if (!suppressWarning)
ExplorerCore.LogWarning("Unable to compile the code!");
}
else
{ {
try try
{ {
object ret = VoidType.Value; Evaluator.Run(code);
compiled.Invoke(ref ret);
}
catch (Exception e)
{
if (!suppressWarning)
ExplorerCore.LogWarning($"Exception executing code: {e.GetType()}, {e.Message}\r\n{e.StackTrace}");
}
}
}
public void ResetConsole() string output = ScriptEvaluator._textWriter.ToString();
{ var outputSplit = output.Split('\n');
if (m_evaluator != null) if (outputSplit.Length >= 2)
{ output = outputSplit[outputSplit.Length - 2];
m_evaluator.Dispose(); m_evalLogBuilder.Clear();
if (ScriptEvaluator._reportPrinter.ErrorsCount > 0)
throw new FormatException($"Unable to compile the code. Evaluator's last output was:\r\n{output}");
if (!supressLog)
ExplorerCore.Log("Code executed successfully.");
}
catch (FormatException fex)
{
if (!supressLog)
ExplorerCore.LogWarning(fex.Message);
}
catch (Exception ex)
{
if (!supressLog)
ExplorerCore.LogWarning(ex);
} }
m_evaluator = new ScriptEvaluator(new StringWriter(new StringBuilder())) { InteractiveBaseClass = typeof(ScriptInteraction) };
UsingDirectives = new List<string>();
} }
// ================================================================================================= // =================================================================================================
@ -160,6 +179,8 @@ The following helper methods are available:
* <color=#add490>Log(""message"")</color> logs a message to the debug console * <color=#add490>Log(""message"")</color> logs a message to the debug console
* <color=#add490>StartCoroutine(IEnumerator routine)</color> start the IEnumerator as a UnityEngine.Coroutine
* <color=#add490>CurrentTarget()</color> returns the currently inspected target on the Home page * <color=#add490>CurrentTarget()</color> returns the currently inspected target on the Home page
* <color=#add490>AllTargets()</color> returns an object[] array containing all inspected instances * <color=#add490>AllTargets()</color> returns an object[] array containing all inspected instances
@ -284,6 +305,7 @@ The following helper methods are available:
return; return;
} }
if (EnableAutoIndent)
UpdateIndent(newText); UpdateIndent(newText);
if (!forceUpdate && string.IsNullOrEmpty(newText)) if (!forceUpdate && string.IsNullOrEmpty(newText))
@ -291,6 +313,7 @@ The following helper methods are available:
else else
inputHighlightText.text = SyntaxHighlightContent(newText); inputHighlightText.text = SyntaxHighlightContent(newText);
if (EnableAutocompletes)
UpdateAutocompletes(); UpdateAutocompletes();
} }
@ -440,8 +463,8 @@ The following helper methods are available:
mainLayout.flexibleHeight = 9000; mainLayout.flexibleHeight = 9000;
var mainGroup = Content.AddComponent<VerticalLayoutGroup>(); var mainGroup = Content.AddComponent<VerticalLayoutGroup>();
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
@ -462,8 +485,8 @@ The following helper methods are available:
topBarGroup.spacing = 10; topBarGroup.spacing = 10;
topBarGroup.childForceExpandHeight = true; topBarGroup.childForceExpandHeight = true;
topBarGroup.childForceExpandWidth = true; topBarGroup.childForceExpandWidth = true;
topBarGroup.childControlWidth = true; topBarGroup.SetChildControlWidth(true);
topBarGroup.childControlHeight = true; topBarGroup.SetChildControlHeight(true);
topBarGroup.childAlignment = TextAnchor.LowerCenter; topBarGroup.childAlignment = TextAnchor.LowerCenter;
var topBarLabel = UIFactory.CreateLabel(topBarObj, TextAnchor.MiddleLeft); var topBarLabel = UIFactory.CreateLabel(topBarObj, TextAnchor.MiddleLeft);
@ -554,9 +577,38 @@ The following helper methods are available:
#endregion #endregion
#region COMPILE BUTTON #region COMPILE BUTTON BAR
var compileBtnObj = UIFactory.CreateButton(Content); var horozGroupObj = UIFactory.CreateHorizontalGroup(Content, new Color(1, 1, 1, 0));
var horozGroup = horozGroupObj.GetComponent<HorizontalLayoutGroup>();
horozGroup.padding.left = 2;
horozGroup.padding.top = 2;
horozGroup.padding.right = 2;
horozGroup.padding.bottom = 2;
var resetBtnObj = UIFactory.CreateButton(horozGroupObj);
var resetBtnLayout = resetBtnObj.AddComponent<LayoutElement>();
resetBtnLayout.preferredWidth = 80;
resetBtnLayout.flexibleWidth = 0;
resetBtnLayout.minHeight = 45;
resetBtnLayout.flexibleHeight = 0;
var resetButton = resetBtnObj.GetComponent<Button>();
var resetBtnColors = resetButton.colors;
resetBtnColors.normalColor = "666666".ToColor();
resetButton.colors = resetBtnColors;
var resetBtnText = resetBtnObj.GetComponentInChildren<Text>();
resetBtnText.text = "Reset";
resetBtnText.fontSize = 18;
resetBtnText.color = Color.white;
// Set compile button callback now that we have the Input Field reference
resetButton.onClick.AddListener(ResetCallback);
void ResetCallback()
{
ResetConsole();
}
var compileBtnObj = UIFactory.CreateButton(horozGroupObj);
var compileBtnLayout = compileBtnObj.AddComponent<LayoutElement>(); var compileBtnLayout = compileBtnObj.AddComponent<LayoutElement>();
compileBtnLayout.preferredWidth = 80; compileBtnLayout.preferredWidth = 80;
compileBtnLayout.flexibleWidth = 0; compileBtnLayout.flexibleWidth = 0;

View File

@ -14,7 +14,7 @@ namespace UnityExplorer.UI.Main
{ {
public static DebugConsole Instance { get; private set; } public static DebugConsole Instance { get; private set; }
public static bool LogUnity { get; set; } = ExplorerConfig.Instance.Log_Unity_Debug; public static bool LogUnity { get; set; }
//public static bool SaveToDisk { get; set; } = ModConfig.Instance.Save_Logs_To_Disk; //public static bool SaveToDisk { get; set; } = ModConfig.Instance.Save_Logs_To_Disk;
internal static StreamWriter s_streamWriter; internal static StreamWriter s_streamWriter;
@ -32,9 +32,13 @@ namespace UnityExplorer.UI.Main
public DebugConsole(GameObject parent) public DebugConsole(GameObject parent)
{ {
Instance = this; Instance = this;
LogUnity = ExplorerConfig.Instance.Log_Unity_Debug;
ConstructUI(parent); ConstructUI(parent);
if (ExplorerConfig.Instance.DebugConsole_Hidden)
ToggleShow();
// append messages that logged before we were set up // append messages that logged before we were set up
string preAppend = ""; string preAppend = "";
for (int i = s_preInitMessages.Count - 1; i >= 0; i--) for (int i = s_preInitMessages.Count - 1; i >= 0; i--)
@ -48,9 +52,6 @@ namespace UnityExplorer.UI.Main
// set up IO // set up IO
//if (!SaveToDisk)
// return;
var path = ExplorerCore.EXPLORER_FOLDER + @"\Logs"; var path = ExplorerCore.EXPLORER_FOLDER + @"\Logs";
if (!Directory.Exists(path)) if (!Directory.Exists(path))
@ -80,6 +81,34 @@ namespace UnityExplorer.UI.Main
s_streamWriter.WriteLine(msg); s_streamWriter.WriteLine(msg);
} }
public static bool Hiding;
private GameObject m_logAreaObj;
private Text m_hideBtnText;
private LayoutElement m_mainLayout;
public static Action OnToggleShow;
public void ToggleShow()
{
if (m_logAreaObj.activeSelf)
{
Hiding = true;
m_logAreaObj.SetActive(false);
m_hideBtnText.text = "Show";
m_mainLayout.minHeight = 30;
}
else
{
Hiding = false;
m_logAreaObj.SetActive(true);
m_hideBtnText.text = "Hide";
m_mainLayout.minHeight = 190;
}
OnToggleShow?.Invoke();
}
public static string RemoveInvalidFilenameChars(string s) public static string RemoveInvalidFilenameChars(string s)
{ {
var invalid = Path.GetInvalidFileNameChars(); var invalid = Path.GetInvalidFileNameChars();
@ -129,8 +158,8 @@ namespace UnityExplorer.UI.Main
var mainObj = UIFactory.CreateVerticalGroup(parent, new Color(0.1f, 0.1f, 0.1f, 1.0f)); var mainObj = UIFactory.CreateVerticalGroup(parent, new Color(0.1f, 0.1f, 0.1f, 1.0f));
var mainGroup = mainObj.GetComponent<VerticalLayoutGroup>(); var mainGroup = mainObj.GetComponent<VerticalLayoutGroup>();
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
@ -140,23 +169,23 @@ namespace UnityExplorer.UI.Main
var mask = mainObj.AddComponent<Mask>(); var mask = mainObj.AddComponent<Mask>();
mask.showMaskGraphic = true; mask.showMaskGraphic = true;
var mainLayout = mainObj.AddComponent<LayoutElement>(); m_mainLayout = mainObj.AddComponent<LayoutElement>();
mainLayout.minHeight = 190; m_mainLayout.minHeight = 190;
mainLayout.flexibleHeight = 0; m_mainLayout.flexibleHeight = 0;
#region LOG AREA #region LOG AREA
var logAreaObj = UIFactory.CreateHorizontalGroup(mainObj); m_logAreaObj = UIFactory.CreateHorizontalGroup(mainObj);
var logAreaGroup = logAreaObj.GetComponent<HorizontalLayoutGroup>(); var logAreaGroup = m_logAreaObj.GetComponent<HorizontalLayoutGroup>();
logAreaGroup.childControlHeight = true; logAreaGroup.SetChildControlHeight(true);
logAreaGroup.childControlWidth = true; logAreaGroup.SetChildControlWidth(true);
logAreaGroup.childForceExpandHeight = true; logAreaGroup.childForceExpandHeight = true;
logAreaGroup.childForceExpandWidth = true; logAreaGroup.childForceExpandWidth = true;
var logAreaLayout = logAreaObj.AddComponent<LayoutElement>(); var logAreaLayout = m_logAreaObj.AddComponent<LayoutElement>();
logAreaLayout.preferredHeight = 190; logAreaLayout.preferredHeight = 190;
logAreaLayout.flexibleHeight = 0; logAreaLayout.flexibleHeight = 0;
var inputScrollerObj = UIFactory.CreateSrollInputField(logAreaObj, out InputFieldScroller inputScroll, 14, new Color(0.05f, 0.05f, 0.05f)); var inputScrollerObj = UIFactory.CreateSrollInputField(m_logAreaObj, out InputFieldScroller inputScroll, 14, new Color(0.05f, 0.05f, 0.05f));
inputScroll.inputField.textComponent.font = UIManager.ConsoleFont; inputScroll.inputField.textComponent.font = UIManager.ConsoleFont;
inputScroll.inputField.readOnly = true; inputScroll.inputField.readOnly = true;
@ -179,8 +208,8 @@ namespace UnityExplorer.UI.Main
bottomGroup.spacing = 10; bottomGroup.spacing = 10;
bottomGroup.childForceExpandHeight = true; bottomGroup.childForceExpandHeight = true;
bottomGroup.childForceExpandWidth = false; bottomGroup.childForceExpandWidth = false;
bottomGroup.childControlWidth = true; bottomGroup.SetChildControlWidth(true);
bottomGroup.childControlHeight = true; bottomGroup.SetChildControlHeight(true);
bottomGroup.childAlignment = TextAnchor.MiddleLeft; bottomGroup.childAlignment = TextAnchor.MiddleLeft;
// Debug Console label // Debug Console label
@ -198,26 +227,15 @@ namespace UnityExplorer.UI.Main
var hideButtonObj = UIFactory.CreateButton(bottomBarObj); var hideButtonObj = UIFactory.CreateButton(bottomBarObj);
var hideBtnText = hideButtonObj.GetComponentInChildren<Text>(); m_hideBtnText = hideButtonObj.GetComponentInChildren<Text>();
hideBtnText.text = "Hide"; m_hideBtnText.text = "Hide";
var hideButton = hideButtonObj.GetComponent<Button>(); var hideButton = hideButtonObj.GetComponent<Button>();
hideButton.onClick.AddListener(HideCallback); hideButton.onClick.AddListener(HideCallback);
void HideCallback() void HideCallback()
{ {
if (logAreaObj.activeSelf) ToggleShow();
{
logAreaObj.SetActive(false);
hideBtnText.text = "Show";
mainLayout.minHeight = 30;
}
else
{
logAreaObj.SetActive(true);
hideBtnText.text = "Hide";
mainLayout.minHeight = 190;
}
} }
var hideBtnColors = hideButton.colors; var hideBtnColors = hideButton.colors;

View File

@ -47,8 +47,8 @@ namespace UnityExplorer.UI.Main
mainGroup.spacing = 3; mainGroup.spacing = 3;
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
} }
} }
} }

View File

@ -43,8 +43,8 @@ namespace UnityExplorer.UI.Main.Home
var mainGroup = mainObj.GetComponent<VerticalLayoutGroup>(); var mainGroup = mainObj.GetComponent<VerticalLayoutGroup>();
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.spacing = 4; mainGroup.spacing = 4;
mainGroup.padding.left = 4; mainGroup.padding.left = 4;
mainGroup.padding.right = 4; mainGroup.padding.right = 4;
@ -54,9 +54,9 @@ namespace UnityExplorer.UI.Main.Home
var topRowObj = UIFactory.CreateHorizontalGroup(mainObj, new Color(1, 1, 1, 0)); var topRowObj = UIFactory.CreateHorizontalGroup(mainObj, new Color(1, 1, 1, 0));
var topRowGroup = topRowObj.GetComponent<HorizontalLayoutGroup>(); var topRowGroup = topRowObj.GetComponent<HorizontalLayoutGroup>();
topRowGroup.childForceExpandWidth = false; topRowGroup.childForceExpandWidth = false;
topRowGroup.childControlWidth = true; topRowGroup.SetChildControlWidth(true);
topRowGroup.childForceExpandHeight = true; topRowGroup.childForceExpandHeight = true;
topRowGroup.childControlHeight = true; topRowGroup.SetChildControlHeight(true);
topRowGroup.spacing = 15; topRowGroup.spacing = 15;
var inspectorTitle = UIFactory.CreateLabel(topRowObj, TextAnchor.MiddleLeft); var inspectorTitle = UIFactory.CreateLabel(topRowObj, TextAnchor.MiddleLeft);
@ -87,15 +87,15 @@ namespace UnityExplorer.UI.Main.Home
var inspectorGroup = m_inspectorContent.GetComponent<VerticalLayoutGroup>(); var inspectorGroup = m_inspectorContent.GetComponent<VerticalLayoutGroup>();
inspectorGroup.childForceExpandHeight = true; inspectorGroup.childForceExpandHeight = true;
inspectorGroup.childForceExpandWidth = true; inspectorGroup.childForceExpandWidth = true;
inspectorGroup.childControlHeight = true; inspectorGroup.SetChildControlHeight(true);
inspectorGroup.childControlWidth = true; inspectorGroup.SetChildControlWidth(true);
m_inspectorContent = UIFactory.CreateVerticalGroup(mainObj, new Color(0.1f, 0.1f, 0.1f)); m_inspectorContent = UIFactory.CreateVerticalGroup(mainObj, new Color(0.1f, 0.1f, 0.1f));
var contentGroup = m_inspectorContent.GetComponent<VerticalLayoutGroup>(); var contentGroup = m_inspectorContent.GetComponent<VerticalLayoutGroup>();
contentGroup.childForceExpandHeight = true; contentGroup.childForceExpandHeight = true;
contentGroup.childForceExpandWidth = true; contentGroup.childForceExpandWidth = true;
contentGroup.childControlHeight = true; contentGroup.SetChildControlHeight(true);
contentGroup.childControlWidth = true; contentGroup.SetChildControlWidth(true);
contentGroup.padding.top = 2; contentGroup.padding.top = 2;
contentGroup.padding.left = 2; contentGroup.padding.left = 2;
contentGroup.padding.right = 2; contentGroup.padding.right = 2;
@ -114,8 +114,8 @@ namespace UnityExplorer.UI.Main.Home
var invisGroup = invisObj.GetComponent<HorizontalLayoutGroup>(); var invisGroup = invisObj.GetComponent<HorizontalLayoutGroup>();
invisGroup.childForceExpandWidth = false; invisGroup.childForceExpandWidth = false;
invisGroup.childForceExpandHeight = false; invisGroup.childForceExpandHeight = false;
invisGroup.childControlWidth = true; invisGroup.SetChildControlWidth(true);
invisGroup.childControlHeight = true; invisGroup.SetChildControlHeight(true);
invisGroup.padding.top = 2; invisGroup.padding.top = 2;
invisGroup.padding.bottom = 2; invisGroup.padding.bottom = 2;
invisGroup.padding.left = 2; invisGroup.padding.left = 2;
@ -150,8 +150,7 @@ namespace UnityExplorer.UI.Main.Home
void OnInspectMouseClicked() void OnInspectMouseClicked()
{ {
InspectUnderMouse.Mode = mode; InspectUnderMouse.StartInspect(mode);
InspectUnderMouse.StartInspect();
} }
} }

View File

@ -143,7 +143,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var vertGroup = vertGroupObj.GetComponent<VerticalLayoutGroup>(); var vertGroup = vertGroupObj.GetComponent<VerticalLayoutGroup>();
vertGroup.childForceExpandHeight = true; vertGroup.childForceExpandHeight = true;
vertGroup.childForceExpandWidth = false; vertGroup.childForceExpandWidth = false;
vertGroup.childControlWidth = true; vertGroup.SetChildControlWidth(true);
vertGroup.spacing = 5; vertGroup.spacing = 5;
var vertLayout = vertGroupObj.AddComponent<LayoutElement>(); var vertLayout = vertGroupObj.AddComponent<LayoutElement>();
vertLayout.minWidth = 120; vertLayout.minWidth = 120;
@ -175,9 +175,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(s_childListContent, new Color(0.07f, 0.07f, 0.07f)); GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(s_childListContent, new Color(0.07f, 0.07f, 0.07f));
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
btnGroup.childForceExpandWidth = true; btnGroup.childForceExpandWidth = true;
btnGroup.childControlWidth = true; btnGroup.SetChildControlWidth(true);
btnGroup.childForceExpandHeight = false; btnGroup.childForceExpandHeight = false;
btnGroup.childControlHeight = true; btnGroup.SetChildControlHeight(true);
LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>(); LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>();
btnLayout.flexibleWidth = 320; btnLayout.flexibleWidth = 320;
btnLayout.minHeight = 25; btnLayout.minHeight = 25;

View File

@ -145,7 +145,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var vertGroup = vertGroupObj.GetComponent<VerticalLayoutGroup>(); var vertGroup = vertGroupObj.GetComponent<VerticalLayoutGroup>();
vertGroup.childForceExpandHeight = true; vertGroup.childForceExpandHeight = true;
vertGroup.childForceExpandWidth = false; vertGroup.childForceExpandWidth = false;
vertGroup.childControlWidth = true; vertGroup.SetChildControlWidth(true);
vertGroup.spacing = 5; vertGroup.spacing = 5;
var vertLayout = vertGroupObj.AddComponent<LayoutElement>(); var vertLayout = vertGroupObj.AddComponent<LayoutElement>();
vertLayout.minWidth = 120; vertLayout.minWidth = 120;
@ -178,9 +178,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
GameObject groupObj = UIFactory.CreateHorizontalGroup(s_compListContent, new Color(0.07f, 0.07f, 0.07f)); GameObject groupObj = UIFactory.CreateHorizontalGroup(s_compListContent, new Color(0.07f, 0.07f, 0.07f));
HorizontalLayoutGroup group = groupObj.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup group = groupObj.GetComponent<HorizontalLayoutGroup>();
group.childForceExpandWidth = true; group.childForceExpandWidth = true;
group.childControlWidth = true; group.SetChildControlWidth(true);
group.childForceExpandHeight = false; group.childForceExpandHeight = false;
group.childControlHeight = true; group.SetChildControlHeight(true);
group.childAlignment = TextAnchor.MiddleLeft; group.childAlignment = TextAnchor.MiddleLeft;
LayoutElement groupLayout = groupObj.AddComponent<LayoutElement>(); LayoutElement groupLayout = groupObj.AddComponent<LayoutElement>();
groupLayout.minWidth = 25; groupLayout.minWidth = 25;

View File

@ -247,7 +247,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var controlsObj = UIFactory.CreateVerticalGroup(parent, new Color(0.07f, 0.07f, 0.07f)); var controlsObj = UIFactory.CreateVerticalGroup(parent, new Color(0.07f, 0.07f, 0.07f));
var controlsGroup = controlsObj.GetComponent<VerticalLayoutGroup>(); var controlsGroup = controlsObj.GetComponent<VerticalLayoutGroup>();
controlsGroup.childForceExpandWidth = false; controlsGroup.childForceExpandWidth = false;
controlsGroup.childControlWidth = true; controlsGroup.SetChildControlWidth(true);
controlsGroup.childForceExpandHeight = false; controlsGroup.childForceExpandHeight = false;
controlsGroup.spacing = 5; controlsGroup.spacing = 5;
controlsGroup.padding.top = 4; controlsGroup.padding.top = 4;
@ -260,9 +260,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var topRow = UIFactory.CreateHorizontalGroup(controlsObj, new Color(1, 1, 1, 0)); var topRow = UIFactory.CreateHorizontalGroup(controlsObj, new Color(1, 1, 1, 0));
var topRowGroup = topRow.GetComponent<HorizontalLayoutGroup>(); var topRowGroup = topRow.GetComponent<HorizontalLayoutGroup>();
topRowGroup.childForceExpandWidth = false; topRowGroup.childForceExpandWidth = false;
topRowGroup.childControlWidth = true; topRowGroup.SetChildControlWidth(true);
topRowGroup.childForceExpandHeight = false; topRowGroup.childForceExpandHeight = false;
topRowGroup.childControlHeight = true; topRowGroup.SetChildControlHeight(true);
topRowGroup.spacing = 5; topRowGroup.spacing = 5;
var hideButtonObj = UIFactory.CreateButton(topRow); var hideButtonObj = UIFactory.CreateButton(topRow);
@ -292,10 +292,10 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var contentObj = UIFactory.CreateVerticalGroup(controlsObj, new Color(1, 1, 1, 0)); var contentObj = UIFactory.CreateVerticalGroup(controlsObj, new Color(1, 1, 1, 0));
var contentGroup = contentObj.GetComponent<VerticalLayoutGroup>(); var contentGroup = contentObj.GetComponent<VerticalLayoutGroup>();
contentGroup.childForceExpandHeight = false; contentGroup.childForceExpandHeight = false;
contentGroup.childControlHeight = true; contentGroup.SetChildControlHeight(true);
contentGroup.spacing = 5; contentGroup.spacing = 5;
contentGroup.childForceExpandWidth = true; contentGroup.childForceExpandWidth = true;
contentGroup.childControlWidth = true; contentGroup.SetChildControlWidth(true);
// ~~ add hide button callback now that we have scroll reference ~~ // ~~ add hide button callback now that we have scroll reference ~~
hideButton.onClick.AddListener(OnHideClicked); hideButton.onClick.AddListener(OnHideClicked);
@ -334,9 +334,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var setParentGroupObj = UIFactory.CreateHorizontalGroup(contentObj, new Color(1, 1, 1, 0)); var setParentGroupObj = UIFactory.CreateHorizontalGroup(contentObj, new Color(1, 1, 1, 0));
var setParentGroup = setParentGroupObj.GetComponent<HorizontalLayoutGroup>(); var setParentGroup = setParentGroupObj.GetComponent<HorizontalLayoutGroup>();
setParentGroup.childForceExpandHeight = false; setParentGroup.childForceExpandHeight = false;
setParentGroup.childControlHeight = true; setParentGroup.SetChildControlHeight(true);
setParentGroup.childForceExpandWidth = false; setParentGroup.childForceExpandWidth = false;
setParentGroup.childControlWidth = true; setParentGroup.SetChildControlWidth(true);
setParentGroup.spacing = 5; setParentGroup.spacing = 5;
var setParentLayout = setParentGroupObj.AddComponent<LayoutElement>(); var setParentLayout = setParentGroupObj.AddComponent<LayoutElement>();
setParentLayout.minHeight = 25; setParentLayout.minHeight = 25;
@ -380,9 +380,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var topBarObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var topBarObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var topGroup = topBarObj.GetComponent<HorizontalLayoutGroup>(); var topGroup = topBarObj.GetComponent<HorizontalLayoutGroup>();
topGroup.childForceExpandWidth = false; topGroup.childForceExpandWidth = false;
topGroup.childControlWidth = true; topGroup.SetChildControlWidth(true);
topGroup.childForceExpandHeight = false; topGroup.childForceExpandHeight = false;
topGroup.childControlHeight = true; topGroup.SetChildControlHeight(true);
topGroup.spacing = 5; topGroup.spacing = 5;
var topLayout = topBarObj.AddComponent<LayoutElement>(); var topLayout = topBarObj.AddComponent<LayoutElement>();
topLayout.minHeight = 25; topLayout.minHeight = 25;
@ -462,9 +462,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var rowObject = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowObject = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var rowGroup = rowObject.GetComponent<HorizontalLayoutGroup>(); var rowGroup = rowObject.GetComponent<HorizontalLayoutGroup>();
rowGroup.childForceExpandWidth = false; rowGroup.childForceExpandWidth = false;
rowGroup.childControlWidth = true; rowGroup.SetChildControlWidth(true);
rowGroup.childForceExpandHeight = false; rowGroup.childForceExpandHeight = false;
rowGroup.childControlHeight = true; rowGroup.SetChildControlHeight(true);
rowGroup.spacing = 5; rowGroup.spacing = 5;
var rowLayout = rowObject.AddComponent<LayoutElement>(); var rowLayout = rowObject.AddComponent<LayoutElement>();
rowLayout.minHeight = 25; rowLayout.minHeight = 25;
@ -500,9 +500,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var inputHolder = UIFactory.CreateVerticalGroup(rowObject, new Color(1, 1, 1, 0)); var inputHolder = UIFactory.CreateVerticalGroup(rowObject, new Color(1, 1, 1, 0));
var inputHolderGroup = inputHolder.GetComponent<VerticalLayoutGroup>(); var inputHolderGroup = inputHolder.GetComponent<VerticalLayoutGroup>();
inputHolderGroup.childForceExpandHeight = false; inputHolderGroup.childForceExpandHeight = false;
inputHolderGroup.childControlHeight = true; inputHolderGroup.SetChildControlHeight(true);
inputHolderGroup.childForceExpandWidth = false; inputHolderGroup.childForceExpandWidth = false;
inputHolderGroup.childControlWidth = true; inputHolderGroup.SetChildControlWidth(true);
var inputObj = UIFactory.CreateInputField(inputHolder); var inputObj = UIFactory.CreateInputField(inputHolder);
var input = inputObj.GetComponent<InputField>(); var input = inputObj.GetComponent<InputField>();
@ -556,7 +556,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var bottomRow = UIFactory.CreateHorizontalGroup(contentObj, new Color(1, 1, 1, 0)); var bottomRow = UIFactory.CreateHorizontalGroup(contentObj, new Color(1, 1, 1, 0));
var bottomGroup = bottomRow.GetComponent<HorizontalLayoutGroup>(); var bottomGroup = bottomRow.GetComponent<HorizontalLayoutGroup>();
bottomGroup.childForceExpandWidth = true; bottomGroup.childForceExpandWidth = true;
bottomGroup.childControlWidth = true; bottomGroup.SetChildControlWidth(true);
bottomGroup.spacing = 4; bottomGroup.spacing = 4;
var bottomLayout = bottomRow.AddComponent<LayoutElement>(); var bottomLayout = bottomRow.AddComponent<LayoutElement>();
bottomLayout.minHeight = 25; bottomLayout.minHeight = 25;

View File

@ -141,15 +141,15 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var parentLayout = scrollContent.transform.parent.gameObject.AddComponent<VerticalLayoutGroup>(); var parentLayout = scrollContent.transform.parent.gameObject.AddComponent<VerticalLayoutGroup>();
parentLayout.childForceExpandWidth = true; parentLayout.childForceExpandWidth = true;
parentLayout.childControlWidth = true; parentLayout.SetChildControlWidth(true);
parentLayout.childForceExpandHeight = true; parentLayout.childForceExpandHeight = true;
parentLayout.childControlHeight = true; parentLayout.SetChildControlHeight(true);
var scrollGroup = scrollContent.GetComponent<VerticalLayoutGroup>(); var scrollGroup = scrollContent.GetComponent<VerticalLayoutGroup>();
scrollGroup.childForceExpandHeight = true; scrollGroup.childForceExpandHeight = true;
scrollGroup.childControlHeight = true; scrollGroup.SetChildControlHeight(true);
scrollGroup.childForceExpandWidth = true; scrollGroup.childForceExpandWidth = true;
scrollGroup.childControlWidth = true; scrollGroup.SetChildControlWidth(true);
scrollGroup.spacing = 5; scrollGroup.spacing = 5;
var contentFitter = scrollContent.GetComponent<ContentSizeFitter>(); var contentFitter = scrollContent.GetComponent<ContentSizeFitter>();
contentFitter.verticalFit = ContentSizeFitter.FitMode.Unconstrained; contentFitter.verticalFit = ContentSizeFitter.FitMode.Unconstrained;
@ -175,8 +175,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var pathGroup = m_pathGroupObj.GetComponent<HorizontalLayoutGroup>(); var pathGroup = m_pathGroupObj.GetComponent<HorizontalLayoutGroup>();
pathGroup.childForceExpandHeight = false; pathGroup.childForceExpandHeight = false;
pathGroup.childForceExpandWidth = false; pathGroup.childForceExpandWidth = false;
pathGroup.childControlHeight = false; pathGroup.SetChildControlHeight(false);
pathGroup.childControlWidth = true; pathGroup.SetChildControlWidth(true);
pathGroup.spacing = 5; pathGroup.spacing = 5;
var pathRect = m_pathGroupObj.GetComponent<RectTransform>(); var pathRect = m_pathGroupObj.GetComponent<RectTransform>();
pathRect.sizeDelta = new Vector2(pathRect.sizeDelta.x, 20); pathRect.sizeDelta = new Vector2(pathRect.sizeDelta.x, 20);
@ -215,9 +215,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
hiddenLayout.flexibleWidth = 9000; hiddenLayout.flexibleWidth = 9000;
var hiddenGroup = pathHiddenTextObj.AddComponent<HorizontalLayoutGroup>(); var hiddenGroup = pathHiddenTextObj.AddComponent<HorizontalLayoutGroup>();
hiddenGroup.childForceExpandWidth = true; hiddenGroup.childForceExpandWidth = true;
hiddenGroup.childControlWidth = true; hiddenGroup.SetChildControlWidth(true);
hiddenGroup.childForceExpandHeight = true; hiddenGroup.childForceExpandHeight = true;
hiddenGroup.childControlHeight = true; hiddenGroup.SetChildControlHeight(true);
var pathInputObj = UIFactory.CreateInputField(pathHiddenTextObj); var pathInputObj = UIFactory.CreateInputField(pathHiddenTextObj);
var pathInputRect = pathInputObj.GetComponent<RectTransform>(); var pathInputRect = pathInputObj.GetComponent<RectTransform>();
@ -246,8 +246,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var nameGroup = nameRowObj.GetComponent<HorizontalLayoutGroup>(); var nameGroup = nameRowObj.GetComponent<HorizontalLayoutGroup>();
nameGroup.childForceExpandHeight = false; nameGroup.childForceExpandHeight = false;
nameGroup.childForceExpandWidth = false; nameGroup.childForceExpandWidth = false;
nameGroup.childControlHeight = true; nameGroup.SetChildControlHeight(true);
nameGroup.childControlWidth = true; nameGroup.SetChildControlWidth(true);
nameGroup.spacing = 5; nameGroup.spacing = 5;
var nameRect = nameRowObj.GetComponent<RectTransform>(); var nameRect = nameRowObj.GetComponent<RectTransform>();
nameRect.sizeDelta = new Vector2(nameRect.sizeDelta.x, 25); nameRect.sizeDelta = new Vector2(nameRect.sizeDelta.x, 25);
@ -311,7 +311,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var sceneLayerRow = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f)); var sceneLayerRow = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f));
var sceneLayerGroup = sceneLayerRow.GetComponent<HorizontalLayoutGroup>(); var sceneLayerGroup = sceneLayerRow.GetComponent<HorizontalLayoutGroup>();
sceneLayerGroup.childForceExpandWidth = false; sceneLayerGroup.childForceExpandWidth = false;
sceneLayerGroup.childControlWidth = true; sceneLayerGroup.SetChildControlWidth(true);
sceneLayerGroup.spacing = 5; sceneLayerGroup.spacing = 5;
var layerLabel = UIFactory.CreateLabel(sceneLayerRow, TextAnchor.MiddleCenter); var layerLabel = UIFactory.CreateLabel(sceneLayerRow, TextAnchor.MiddleCenter);
@ -363,9 +363,9 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var midGroup = midGroupObj.GetComponent<HorizontalLayoutGroup>(); var midGroup = midGroupObj.GetComponent<HorizontalLayoutGroup>();
midGroup.spacing = 5; midGroup.spacing = 5;
midGroup.childForceExpandWidth = true; midGroup.childForceExpandWidth = true;
midGroup.childControlWidth = true; midGroup.SetChildControlWidth(true);
midGroup.childForceExpandHeight = true; midGroup.childForceExpandHeight = true;
midGroup.childControlHeight = true; midGroup.SetChildControlHeight(true);
var midLayout = midGroupObj.AddComponent<LayoutElement>(); var midLayout = midGroupObj.AddComponent<LayoutElement>();
midLayout.minHeight = 300; midLayout.minHeight = 300;

View File

@ -21,7 +21,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var tabGroupObj = UIFactory.CreateHorizontalGroup(tabContent); var tabGroupObj = UIFactory.CreateHorizontalGroup(tabContent);
var tabGroup = tabGroupObj.GetComponent<HorizontalLayoutGroup>(); var tabGroup = tabGroupObj.GetComponent<HorizontalLayoutGroup>();
tabGroup.childForceExpandWidth = true; tabGroup.childForceExpandWidth = true;
tabGroup.childControlWidth = true; tabGroup.SetChildControlWidth(true);
var tabLayout = tabGroupObj.AddComponent<LayoutElement>(); var tabLayout = tabGroupObj.AddComponent<LayoutElement>();
tabLayout.minWidth = 185; tabLayout.minWidth = 185;
tabLayout.flexibleWidth = 0; tabLayout.flexibleWidth = 0;

View File

@ -28,7 +28,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var rowObj = UIFactory.CreateHorizontalGroup(Parent.ReflectionUI.Content, new Color(0.1f, 0.1f, 0.1f)); var rowObj = UIFactory.CreateHorizontalGroup(Parent.ReflectionUI.Content, new Color(0.1f, 0.1f, 0.1f));
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>(); var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childForceExpandWidth = true; rowGroup.childForceExpandWidth = true;
rowGroup.childControlWidth = true; rowGroup.SetChildControlWidth(true);
rowGroup.spacing = 5; rowGroup.spacing = 5;
rowGroup.padding.top = 2; rowGroup.padding.top = 2;
rowGroup.padding.bottom = 2; rowGroup.padding.bottom = 2;
@ -137,8 +137,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var viewerGroup = scrollContent.GetComponent<VerticalLayoutGroup>(); var viewerGroup = scrollContent.GetComponent<VerticalLayoutGroup>();
viewerGroup.childForceExpandHeight = false; viewerGroup.childForceExpandHeight = false;
viewerGroup.childForceExpandWidth = false; viewerGroup.childForceExpandWidth = false;
viewerGroup.childControlHeight = true; viewerGroup.SetChildControlHeight(true);
viewerGroup.childControlWidth = true; viewerGroup.SetChildControlWidth(true);
var mainLayout = textureViewerObj.GetComponent<LayoutElement>(); var mainLayout = textureViewerObj.GetComponent<LayoutElement>();
mainLayout.flexibleHeight = 9999; mainLayout.flexibleHeight = 9999;
mainLayout.flexibleWidth = 9999; mainLayout.flexibleWidth = 9999;
@ -275,8 +275,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var memFilterGroup = memberFilterRowObj.GetComponent<HorizontalLayoutGroup>(); var memFilterGroup = memberFilterRowObj.GetComponent<HorizontalLayoutGroup>();
memFilterGroup.childForceExpandHeight = false; memFilterGroup.childForceExpandHeight = false;
memFilterGroup.childForceExpandWidth = false; memFilterGroup.childForceExpandWidth = false;
memFilterGroup.childControlWidth = true; memFilterGroup.SetChildControlWidth(true);
memFilterGroup.childControlHeight = true; memFilterGroup.SetChildControlHeight(true);
memFilterGroup.spacing = 5; memFilterGroup.spacing = 5;
var memFilterLayout = memberFilterRowObj.AddComponent<LayoutElement>(); var memFilterLayout = memberFilterRowObj.AddComponent<LayoutElement>();
memFilterLayout.minHeight = 25; memFilterLayout.minHeight = 25;

View File

@ -53,8 +53,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var mainGroup = Content.GetComponent<VerticalLayoutGroup>(); var mainGroup = Content.GetComponent<VerticalLayoutGroup>();
mainGroup.childForceExpandHeight = false; mainGroup.childForceExpandHeight = false;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.spacing = 5; mainGroup.spacing = 5;
mainGroup.padding.top = 4; mainGroup.padding.top = 4;
mainGroup.padding.left = 4; mainGroup.padding.left = 4;
@ -72,8 +72,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var nameRow = nameRowObj.GetComponent<HorizontalLayoutGroup>(); var nameRow = nameRowObj.GetComponent<HorizontalLayoutGroup>();
nameRow.childForceExpandWidth = true; nameRow.childForceExpandWidth = true;
nameRow.childForceExpandHeight = true; nameRow.childForceExpandHeight = true;
nameRow.childControlHeight = true; nameRow.SetChildControlHeight(true);
nameRow.childControlWidth = true; nameRow.SetChildControlWidth(true);
nameRow.padding.top = 2; nameRow.padding.top = 2;
var nameRowLayout = nameRowObj.AddComponent<LayoutElement>(); var nameRowLayout = nameRowObj.AddComponent<LayoutElement>();
nameRowLayout.minHeight = 25; nameRowLayout.minHeight = 25;
@ -120,8 +120,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var filterGroup = filterAreaObj.GetComponent<VerticalLayoutGroup>(); var filterGroup = filterAreaObj.GetComponent<VerticalLayoutGroup>();
filterGroup.childForceExpandWidth = true; filterGroup.childForceExpandWidth = true;
filterGroup.childForceExpandHeight = true; filterGroup.childForceExpandHeight = true;
filterGroup.childControlWidth = true; filterGroup.SetChildControlWidth(true);
filterGroup.childControlHeight = true; filterGroup.SetChildControlHeight(true);
filterGroup.spacing = 4; filterGroup.spacing = 4;
filterGroup.padding.left = 4; filterGroup.padding.left = 4;
filterGroup.padding.right = 4; filterGroup.padding.right = 4;
@ -136,8 +136,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var nameFilterGroup = nameFilterRowObj.GetComponent<HorizontalLayoutGroup>(); var nameFilterGroup = nameFilterRowObj.GetComponent<HorizontalLayoutGroup>();
nameFilterGroup.childForceExpandHeight = false; nameFilterGroup.childForceExpandHeight = false;
nameFilterGroup.childForceExpandWidth = false; nameFilterGroup.childForceExpandWidth = false;
nameFilterGroup.childControlWidth = true; nameFilterGroup.SetChildControlWidth(true);
nameFilterGroup.childControlHeight = true; nameFilterGroup.SetChildControlHeight(true);
nameFilterGroup.spacing = 5; nameFilterGroup.spacing = 5;
var nameFilterLayout = nameFilterRowObj.AddComponent<LayoutElement>(); var nameFilterLayout = nameFilterRowObj.AddComponent<LayoutElement>();
nameFilterLayout.minHeight = 25; nameFilterLayout.minHeight = 25;
@ -168,8 +168,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var memFilterGroup = memberFilterRowObj.GetComponent<HorizontalLayoutGroup>(); var memFilterGroup = memberFilterRowObj.GetComponent<HorizontalLayoutGroup>();
memFilterGroup.childForceExpandHeight = false; memFilterGroup.childForceExpandHeight = false;
memFilterGroup.childForceExpandWidth = false; memFilterGroup.childForceExpandWidth = false;
memFilterGroup.childControlWidth = true; memFilterGroup.SetChildControlWidth(true);
memFilterGroup.childControlHeight = true; memFilterGroup.SetChildControlHeight(true);
memFilterGroup.spacing = 5; memFilterGroup.spacing = 5;
var memFilterLayout = memberFilterRowObj.AddComponent<LayoutElement>(); var memFilterLayout = memberFilterRowObj.AddComponent<LayoutElement>();
memFilterLayout.minHeight = 25; memFilterLayout.minHeight = 25;

View File

@ -12,7 +12,14 @@ namespace UnityExplorer.UI.Main.Home
{ {
public class SceneExplorerUI public class SceneExplorerUI
{ {
internal static bool Hiding; public static SceneExplorerUI Instance;
public SceneExplorerUI()
{
Instance = this;
}
internal bool Hiding;
private Dropdown m_sceneDropdown; private Dropdown m_sceneDropdown;
private Text m_sceneDropdownText; private Text m_sceneDropdownText;
@ -27,6 +34,46 @@ namespace UnityExplorer.UI.Main.Home
internal readonly List<GameObject> m_shortList = new List<GameObject>(); internal readonly List<GameObject> m_shortList = new List<GameObject>();
private Text hideText;
private GameObject m_titleObj;
private GameObject m_sceneDropdownObj;
private GameObject m_scenePathGroupObj;
private GameObject m_scrollObj;
private LayoutElement m_leftLayout;
public void ToggleShow()
{
if (!Hiding)
{
Hiding = true;
hideText.text = "►";
m_titleObj.SetActive(false);
m_sceneDropdownObj.SetActive(false);
m_scenePathGroupObj.SetActive(false);
m_scrollObj.SetActive(false);
m_pageHandler.Hide();
m_leftLayout.minWidth = 15;
}
else
{
Hiding = false;
hideText.text = "Hide Scene Explorer";
m_titleObj.SetActive(true);
m_sceneDropdownObj.SetActive(true);
m_scenePathGroupObj.SetActive(true);
m_scrollObj.SetActive(true);
m_leftLayout.minWidth = 350;
SceneExplorer.Instance.Update();
}
SceneExplorer.InvokeOnToggleShow();
}
public void OnActiveScenesChanged(List<string> newNames) public void OnActiveScenesChanged(List<string> newNames)
{ {
m_sceneDropdown.options.Clear(); m_sceneDropdown.options.Clear();
@ -160,9 +207,9 @@ namespace UnityExplorer.UI.Main.Home
public void ConstructScenePane() public void ConstructScenePane()
{ {
GameObject leftPane = UIFactory.CreateVerticalGroup(HomePage.Instance.Content, new Color(72f / 255f, 72f / 255f, 72f / 255f)); GameObject leftPane = UIFactory.CreateVerticalGroup(HomePage.Instance.Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
LayoutElement leftLayout = leftPane.AddComponent<LayoutElement>(); m_leftLayout = leftPane.AddComponent<LayoutElement>();
leftLayout.minWidth = 350; m_leftLayout.minWidth = 350;
leftLayout.flexibleWidth = 0; m_leftLayout.flexibleWidth = 0;
VerticalLayoutGroup leftGroup = leftPane.GetComponent<VerticalLayoutGroup>(); VerticalLayoutGroup leftGroup = leftPane.GetComponent<VerticalLayoutGroup>();
leftGroup.padding.left = 4; leftGroup.padding.left = 4;
@ -170,21 +217,21 @@ namespace UnityExplorer.UI.Main.Home
leftGroup.padding.top = 8; leftGroup.padding.top = 8;
leftGroup.padding.bottom = 4; leftGroup.padding.bottom = 4;
leftGroup.spacing = 4; leftGroup.spacing = 4;
leftGroup.childControlWidth = true; leftGroup.SetChildControlWidth(true);
leftGroup.childControlHeight = true; leftGroup.SetChildControlHeight(true);
leftGroup.childForceExpandWidth = true; leftGroup.childForceExpandWidth = true;
leftGroup.childForceExpandHeight = true; leftGroup.childForceExpandHeight = true;
GameObject titleObj = UIFactory.CreateLabel(leftPane, TextAnchor.UpperLeft); m_titleObj = UIFactory.CreateLabel(leftPane, TextAnchor.UpperLeft);
Text titleLabel = titleObj.GetComponent<Text>(); Text titleLabel = m_titleObj.GetComponent<Text>();
titleLabel.text = "Scene Explorer"; titleLabel.text = "Scene Explorer";
titleLabel.fontSize = 20; titleLabel.fontSize = 20;
LayoutElement titleLayout = titleObj.AddComponent<LayoutElement>(); LayoutElement titleLayout = m_titleObj.AddComponent<LayoutElement>();
titleLayout.minHeight = 30; titleLayout.minHeight = 30;
titleLayout.flexibleHeight = 0; titleLayout.flexibleHeight = 0;
GameObject sceneDropdownObj = UIFactory.CreateDropdown(leftPane, out m_sceneDropdown); m_sceneDropdownObj = UIFactory.CreateDropdown(leftPane, out m_sceneDropdown);
LayoutElement dropdownLayout = sceneDropdownObj.AddComponent<LayoutElement>(); LayoutElement dropdownLayout = m_sceneDropdownObj.AddComponent<LayoutElement>();
dropdownLayout.minHeight = 40; dropdownLayout.minHeight = 40;
dropdownLayout.flexibleHeight = 0; dropdownLayout.flexibleHeight = 0;
dropdownLayout.minWidth = 320; dropdownLayout.minWidth = 320;
@ -199,19 +246,19 @@ namespace UnityExplorer.UI.Main.Home
SceneExplorer.Instance.SetTargetScene(val); SceneExplorer.Instance.SetTargetScene(val);
} }
GameObject scenePathGroupObj = UIFactory.CreateHorizontalGroup(leftPane, new Color(1, 1, 1, 0f)); m_scenePathGroupObj = UIFactory.CreateHorizontalGroup(leftPane, new Color(1, 1, 1, 0f));
HorizontalLayoutGroup scenePathGroup = scenePathGroupObj.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup scenePathGroup = m_scenePathGroupObj.GetComponent<HorizontalLayoutGroup>();
scenePathGroup.childControlHeight = true; scenePathGroup.SetChildControlHeight(true);
scenePathGroup.childControlWidth = true; scenePathGroup.SetChildControlWidth(true);
scenePathGroup.childForceExpandHeight = true; scenePathGroup.childForceExpandHeight = true;
scenePathGroup.childForceExpandWidth = true; scenePathGroup.childForceExpandWidth = true;
scenePathGroup.spacing = 5; scenePathGroup.spacing = 5;
LayoutElement scenePathLayout = scenePathGroupObj.AddComponent<LayoutElement>(); LayoutElement scenePathLayout = m_scenePathGroupObj.AddComponent<LayoutElement>();
scenePathLayout.minHeight = 20; scenePathLayout.minHeight = 20;
scenePathLayout.minWidth = 335; scenePathLayout.minWidth = 335;
scenePathLayout.flexibleWidth = 0; scenePathLayout.flexibleWidth = 0;
m_backButtonObj = UIFactory.CreateButton(scenePathGroupObj); m_backButtonObj = UIFactory.CreateButton(m_scenePathGroupObj);
Text backButtonText = m_backButtonObj.GetComponentInChildren<Text>(); Text backButtonText = m_backButtonObj.GetComponentInChildren<Text>();
backButtonText.text = "◄"; backButtonText.text = "◄";
LayoutElement backButtonLayout = m_backButtonObj.AddComponent<LayoutElement>(); LayoutElement backButtonLayout = m_backButtonObj.AddComponent<LayoutElement>();
@ -224,7 +271,7 @@ namespace UnityExplorer.UI.Main.Home
backButton.onClick.AddListener(() => { SceneExplorer.Instance.SetSceneObjectParent(); }); backButton.onClick.AddListener(() => { SceneExplorer.Instance.SetSceneObjectParent(); });
GameObject scenePathLabel = UIFactory.CreateHorizontalGroup(scenePathGroupObj); GameObject scenePathLabel = UIFactory.CreateHorizontalGroup(m_scenePathGroupObj);
Image image = scenePathLabel.GetComponent<Image>(); Image image = scenePathLabel.GetComponent<Image>();
image.color = Color.white; image.color = Color.white;
@ -248,7 +295,7 @@ namespace UnityExplorer.UI.Main.Home
textLayout.minHeight = 20; textLayout.minHeight = 20;
textLayout.flexibleHeight = 0; textLayout.flexibleHeight = 0;
m_mainInspectBtn = UIFactory.CreateButton(scenePathGroupObj); m_mainInspectBtn = UIFactory.CreateButton(m_scenePathGroupObj);
Text inspectButtonText = m_mainInspectBtn.GetComponentInChildren<Text>(); Text inspectButtonText = m_mainInspectBtn.GetComponentInChildren<Text>();
inspectButtonText.text = "Inspect"; inspectButtonText.text = "Inspect";
LayoutElement inspectButtonLayout = m_mainInspectBtn.AddComponent<LayoutElement>(); LayoutElement inspectButtonLayout = m_mainInspectBtn.AddComponent<LayoutElement>();
@ -261,7 +308,7 @@ namespace UnityExplorer.UI.Main.Home
inspectButton.onClick.AddListener(() => { SceneExplorer.InspectSelectedGameObject(); }); inspectButton.onClick.AddListener(() => { SceneExplorer.InspectSelectedGameObject(); });
GameObject scrollObj = UIFactory.CreateScrollView(leftPane, out m_pageContent, out SliderScrollbar scroller, new Color(0.1f, 0.1f, 0.1f)); m_scrollObj = UIFactory.CreateScrollView(leftPane, out m_pageContent, out SliderScrollbar scroller, new Color(0.1f, 0.1f, 0.1f));
m_pageHandler = new PageHandler(scroller); m_pageHandler = new PageHandler(scroller);
m_pageHandler.ConstructUI(leftPane); m_pageHandler.ConstructUI(leftPane);
@ -275,47 +322,14 @@ namespace UnityExplorer.UI.Main.Home
var hideColors = hideBtn.colors; var hideColors = hideBtn.colors;
hideColors.normalColor = new Color(0.15f, 0.15f, 0.15f); hideColors.normalColor = new Color(0.15f, 0.15f, 0.15f);
hideBtn.colors = hideColors; hideBtn.colors = hideColors;
var hideText = hideButtonObj.GetComponentInChildren<Text>(); hideText = hideButtonObj.GetComponentInChildren<Text>();
hideText.text = "Hide Scene Explorer"; hideText.text = "Hide Scene Explorer";
hideText.fontSize = 13; hideText.fontSize = 13;
var hideLayout = hideButtonObj.AddComponent<LayoutElement>(); var hideLayout = hideButtonObj.AddComponent<LayoutElement>();
hideLayout.minWidth = 20; hideLayout.minWidth = 20;
hideLayout.minHeight = 20; hideLayout.minHeight = 20;
hideBtn.onClick.AddListener(OnHide); hideBtn.onClick.AddListener(ToggleShow);
void OnHide()
{
if (!Hiding)
{
Hiding = true;
hideText.text = "►";
titleObj.SetActive(false);
sceneDropdownObj.SetActive(false);
scenePathGroupObj.SetActive(false);
scrollObj.SetActive(false);
m_pageHandler.Hide();
leftLayout.minWidth = 15;
}
else
{
Hiding = false;
hideText.text = "Hide Scene Explorer";
titleObj.SetActive(true);
sceneDropdownObj.SetActive(true);
scenePathGroupObj.SetActive(true);
scrollObj.SetActive(true);
leftLayout.minWidth = 350;
SceneExplorer.Instance.Update();
}
SceneExplorer.InvokeOnToggleShow();
}
} }
private void AddObjectListButton() private void AddObjectListButton()
@ -325,9 +339,9 @@ namespace UnityExplorer.UI.Main.Home
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_pageContent, new Color(0.1f, 0.1f, 0.1f)); GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_pageContent, new Color(0.1f, 0.1f, 0.1f));
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
btnGroup.childForceExpandWidth = true; btnGroup.childForceExpandWidth = true;
btnGroup.childControlWidth = true; btnGroup.SetChildControlWidth(true);
btnGroup.childForceExpandHeight = false; btnGroup.childForceExpandHeight = false;
btnGroup.childControlHeight = true; btnGroup.SetChildControlHeight(true);
LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>(); LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>();
btnLayout.flexibleWidth = 320; btnLayout.flexibleWidth = 320;
btnLayout.minHeight = 25; btnLayout.minHeight = 25;

View File

@ -22,6 +22,8 @@ namespace UnityExplorer.UI.Main
public readonly List<BaseMenuPage> Pages = new List<BaseMenuPage>(); public readonly List<BaseMenuPage> Pages = new List<BaseMenuPage>();
private BaseMenuPage m_activePage; private BaseMenuPage m_activePage;
public static Action<int> OnActiveTabChanged;
// Navbar buttons // Navbar buttons
private Button m_lastNavButtonPressed; private Button m_lastNavButtonPressed;
private readonly Color m_navButtonNormal = new Color(0.3f, 0.3f, 0.3f, 1); private readonly Color m_navButtonNormal = new Color(0.3f, 0.3f, 0.3f, 1);
@ -72,10 +74,15 @@ namespace UnityExplorer.UI.Main
internal bool pageLayoutInit; internal bool pageLayoutInit;
internal int layoutInitIndex; internal int layoutInitIndex;
private int origDesiredPage = -1;
public void Update() public void Update()
{ {
if (!pageLayoutInit) if (!pageLayoutInit)
{ {
if (origDesiredPage == -1)
origDesiredPage = ExplorerConfig.Instance?.Active_Tab ?? 0;
if (layoutInitIndex < Pages.Count) if (layoutInitIndex < Pages.Count)
{ {
SetPage(Pages[layoutInitIndex]); SetPage(Pages[layoutInitIndex]);
@ -85,7 +92,7 @@ namespace UnityExplorer.UI.Main
{ {
pageLayoutInit = true; pageLayoutInit = true;
MainPanel.transform.position = initPos; MainPanel.transform.position = initPos;
SetPage(Pages[0]); SetPage(Pages[origDesiredPage]);
} }
return; return;
} }
@ -98,19 +105,6 @@ namespace UnityExplorer.UI.Main
if (page == null || m_activePage == page) if (page == null || m_activePage == page)
return; return;
// WIP, was going to hide current page if you press current page's button,
// but the main panel does not resize so its just a big empty gap there.
// Could be good if I resize that gap, not bothering for now.
// Would need a fix in PanelDragger as well.
//if (m_activePage == page)
//{
// SetButtonInactiveColors(page.RefNavbarButton);
// m_activePage.Content.SetActive(false);
// m_activePage = null;
// return;
//}
m_activePage?.Content?.SetActive(false); m_activePage?.Content?.SetActive(false);
// unique case for console page, at the moment this will just go here // unique case for console page, at the moment this will just go here
@ -128,6 +122,8 @@ namespace UnityExplorer.UI.Main
SetButtonInactiveColors(m_lastNavButtonPressed); SetButtonInactiveColors(m_lastNavButtonPressed);
m_lastNavButtonPressed = button; m_lastNavButtonPressed = button;
OnActiveTabChanged?.Invoke(Pages.IndexOf(m_activePage));
} }
internal void SetButtonActiveColors(Button button) internal void SetButtonActiveColors(Button button)
@ -184,8 +180,8 @@ namespace UnityExplorer.UI.Main
GameObject titleBar = UIFactory.CreateHorizontalGroup(content); GameObject titleBar = UIFactory.CreateHorizontalGroup(content);
HorizontalLayoutGroup titleGroup = titleBar.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup titleGroup = titleBar.GetComponent<HorizontalLayoutGroup>();
titleGroup.childControlHeight = true; titleGroup.SetChildControlHeight(true);
titleGroup.childControlWidth = true; titleGroup.SetChildControlWidth(true);
titleGroup.childForceExpandHeight = true; titleGroup.childForceExpandHeight = true;
titleGroup.childForceExpandWidth = true; titleGroup.childForceExpandWidth = true;
titleGroup.padding.left = 15; titleGroup.padding.left = 15;
@ -248,8 +244,8 @@ namespace UnityExplorer.UI.Main
HorizontalLayoutGroup navGroup = navbarObj.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup navGroup = navbarObj.GetComponent<HorizontalLayoutGroup>();
navGroup.spacing = 5; navGroup.spacing = 5;
navGroup.childControlHeight = true; navGroup.SetChildControlHeight(true);
navGroup.childControlWidth = true; navGroup.SetChildControlWidth(true);
navGroup.childForceExpandHeight = true; navGroup.childForceExpandHeight = true;
navGroup.childForceExpandWidth = true; navGroup.childForceExpandWidth = true;
@ -283,8 +279,8 @@ namespace UnityExplorer.UI.Main
{ {
GameObject mainObj = UIFactory.CreateHorizontalGroup(content); GameObject mainObj = UIFactory.CreateHorizontalGroup(content);
HorizontalLayoutGroup mainGroup = mainObj.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup mainGroup = mainObj.GetComponent<HorizontalLayoutGroup>();
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;

View File

@ -62,8 +62,8 @@ namespace UnityExplorer.UI.Main
mainGroup.spacing = 5; mainGroup.spacing = 5;
mainGroup.childForceExpandHeight = false; mainGroup.childForceExpandHeight = false;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
// ~~~~~ Title ~~~~~ // ~~~~~ Title ~~~~~
@ -81,8 +81,8 @@ namespace UnityExplorer.UI.Main
var optionsGroup = optionsGroupObj.GetComponent<VerticalLayoutGroup>(); var optionsGroup = optionsGroupObj.GetComponent<VerticalLayoutGroup>();
optionsGroup.childForceExpandHeight = false; optionsGroup.childForceExpandHeight = false;
optionsGroup.childForceExpandWidth = true; optionsGroup.childForceExpandWidth = true;
optionsGroup.childControlWidth = true; optionsGroup.SetChildControlWidth(true);
optionsGroup.childControlHeight = true; optionsGroup.SetChildControlHeight(true);
optionsGroup.spacing = 5; optionsGroup.spacing = 5;
optionsGroup.padding.top = 5; optionsGroup.padding.top = 5;
optionsGroup.padding.left = 5; optionsGroup.padding.left = 5;
@ -113,9 +113,9 @@ namespace UnityExplorer.UI.Main
{ {
var rowObj = UIFactory.CreateHorizontalGroup(optionsGroupObj, new Color(1, 1, 1, 0)); var rowObj = UIFactory.CreateHorizontalGroup(optionsGroupObj, new Color(1, 1, 1, 0));
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>(); var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childControlWidth = true; rowGroup.SetChildControlWidth(true);
rowGroup.childForceExpandWidth = false; rowGroup.childForceExpandWidth = false;
rowGroup.childControlHeight = true; rowGroup.SetChildControlHeight(true);
rowGroup.childForceExpandHeight = true; rowGroup.childForceExpandHeight = true;
var groupLayout = rowObj.AddComponent<LayoutElement>(); var groupLayout = rowObj.AddComponent<LayoutElement>();
groupLayout.minHeight = 25; groupLayout.minHeight = 25;
@ -139,9 +139,9 @@ namespace UnityExplorer.UI.Main
{ {
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>(); var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childControlWidth = true; rowGroup.SetChildControlWidth(true);
rowGroup.childForceExpandWidth = false; rowGroup.childForceExpandWidth = false;
rowGroup.childControlHeight = true; rowGroup.SetChildControlHeight(true);
rowGroup.childForceExpandHeight = true; rowGroup.childForceExpandHeight = true;
var groupLayout = rowObj.AddComponent<LayoutElement>(); var groupLayout = rowObj.AddComponent<LayoutElement>();
groupLayout.minHeight = 25; groupLayout.minHeight = 25;
@ -168,9 +168,9 @@ namespace UnityExplorer.UI.Main
{ {
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>(); var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childControlWidth = true; rowGroup.SetChildControlWidth(true);
rowGroup.childForceExpandWidth = false; rowGroup.childForceExpandWidth = false;
rowGroup.childControlHeight = true; rowGroup.SetChildControlHeight(true);
rowGroup.childForceExpandHeight = true; rowGroup.childForceExpandHeight = true;
var groupLayout = rowObj.AddComponent<LayoutElement>(); var groupLayout = rowObj.AddComponent<LayoutElement>();
groupLayout.minHeight = 25; groupLayout.minHeight = 25;
@ -196,9 +196,9 @@ namespace UnityExplorer.UI.Main
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>(); var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childControlWidth = true; rowGroup.SetChildControlWidth(true);
rowGroup.childForceExpandWidth = false; rowGroup.childForceExpandWidth = false;
rowGroup.childControlHeight = true; rowGroup.SetChildControlHeight(true);
rowGroup.childForceExpandHeight = true; rowGroup.childForceExpandHeight = true;
var groupLayout = rowObj.AddComponent<LayoutElement>(); var groupLayout = rowObj.AddComponent<LayoutElement>();
groupLayout.minHeight = 25; groupLayout.minHeight = 25;
@ -227,9 +227,9 @@ namespace UnityExplorer.UI.Main
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>(); var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childControlWidth = true; rowGroup.SetChildControlWidth(true);
rowGroup.childForceExpandWidth = false; rowGroup.childForceExpandWidth = false;
rowGroup.childControlHeight = true; rowGroup.SetChildControlHeight(true);
rowGroup.childForceExpandHeight = true; rowGroup.childForceExpandHeight = true;
var groupLayout = rowObj.AddComponent<LayoutElement>(); var groupLayout = rowObj.AddComponent<LayoutElement>();
groupLayout.minHeight = 25; groupLayout.minHeight = 25;

View File

@ -5,6 +5,7 @@ using UnityEngine.UI;
using UnityExplorer.Core.Input; using UnityExplorer.Core.Input;
using System.IO; using System.IO;
using UnityExplorer.Core.Inspectors; using UnityExplorer.Core.Inspectors;
using System.Diagnostics;
namespace UnityExplorer.UI namespace UnityExplorer.UI
{ {
@ -39,7 +40,7 @@ namespace UnityExplorer.UI
Vector3 dragPos = DragableArea.InverseTransformPoint(rawMousePos); Vector3 dragPos = DragableArea.InverseTransformPoint(rawMousePos);
bool inDragPos = DragableArea.rect.Contains(dragPos); bool inDragPos = DragableArea.rect.Contains(dragPos);
if (WasHoveringResize && s_resizeCursorImage) if (WasHoveringResize && s_resizeCursorObj)
{ {
UpdateHoverImagePos(); UpdateHoverImagePos();
} }
@ -141,16 +142,16 @@ namespace UnityExplorer.UI
private bool WasHoveringResize { get; set; } private bool WasHoveringResize { get; set; }
private ResizeTypes m_lastResizeHoverType; private ResizeTypes m_lastResizeHoverType;
public static GameObject s_resizeCursorImage; public static GameObject s_resizeCursorObj;
private Rect m_resizeRect; private Rect m_resizeRect;
private readonly Dictionary<ResizeTypes, Rect> m_resizeMask = new Dictionary<ResizeTypes, Rect> private readonly Dictionary<ResizeTypes, Rect> m_resizeMask = new Dictionary<ResizeTypes, Rect>
{ {
{ ResizeTypes.Top, Rect.zero }, { ResizeTypes.Top, default },
{ ResizeTypes.Left, Rect.zero }, { ResizeTypes.Left, default },
{ ResizeTypes.Right, Rect.zero }, { ResizeTypes.Right, default },
{ ResizeTypes.Bottom, Rect.zero }, { ResizeTypes.Bottom, default },
}; };
[Flags] [Flags]
@ -167,15 +168,15 @@ namespace UnityExplorer.UI
BottomRight = Bottom | Right, BottomRight = Bottom | Right,
} }
private const int HALF_THICKESS = RESIZE_THICKNESS / 2;
private const int DBL_THICKNESS = RESIZE_THICKNESS* 2;
private void UpdateResizeCache() private void UpdateResizeCache()
{ {
int halfThick = RESIZE_THICKNESS / 2; m_resizeRect = new Rect(Panel.rect.x - HALF_THICKESS,
int dblThick = RESIZE_THICKNESS * 2; Panel.rect.y - HALF_THICKESS,
Panel.rect.width + DBL_THICKNESS,
m_resizeRect = new Rect(Panel.rect.x - halfThick, Panel.rect.height + DBL_THICKNESS);
Panel.rect.y - halfThick,
Panel.rect.width + dblThick,
Panel.rect.height + dblThick);
// calculate the four cross sections to use as flags // calculate the four cross sections to use as flags
@ -196,20 +197,25 @@ namespace UnityExplorer.UI
private ResizeTypes GetResizeType(Vector2 mousePos) private ResizeTypes GetResizeType(Vector2 mousePos)
{ {
// Calculate which part of the resize area we're in, if any. // Calculate which part of the resize area we're in, if any.
// More readable method commented out below.
ResizeTypes mask = 0; int mask = 0;
mask |= (int)ResizeTypes.Top * (m_resizeMask[ResizeTypes.Top].Contains(mousePos) ? 1 : 0);
mask |= (int)ResizeTypes.Bottom * (m_resizeMask[ResizeTypes.Bottom].Contains(mousePos) ? 1 : 0);
mask |= (int)ResizeTypes.Left * (m_resizeMask[ResizeTypes.Left].Contains(mousePos) ? 1 : 0);
mask |= (int)ResizeTypes.Right * (m_resizeMask[ResizeTypes.Right].Contains(mousePos) ? 1 : 0);
if (m_resizeMask[ResizeTypes.Top].Contains(mousePos)) //if (m_resizeMask[ResizeTypes.Top].Contains(mousePos))
mask |= ResizeTypes.Top; // mask |= ResizeTypes.Top;
else if (m_resizeMask[ResizeTypes.Bottom].Contains(mousePos)) //else if (m_resizeMask[ResizeTypes.Bottom].Contains(mousePos))
mask |= ResizeTypes.Bottom; // mask |= ResizeTypes.Bottom;
if (m_resizeMask[ResizeTypes.Left].Contains(mousePos)) //if (m_resizeMask[ResizeTypes.Left].Contains(mousePos))
mask |= ResizeTypes.Left; // mask |= ResizeTypes.Left;
else if (m_resizeMask[ResizeTypes.Right].Contains(mousePos)) //else if (m_resizeMask[ResizeTypes.Right].Contains(mousePos))
mask |= ResizeTypes.Right; // mask |= ResizeTypes.Right;
return mask; return (ResizeTypes)mask;
} }
public void OnHoverResize(ResizeTypes resizeType) public void OnHoverResize(ResizeTypes resizeType)
@ -222,7 +228,7 @@ namespace UnityExplorer.UI
WasHoveringResize = true; WasHoveringResize = true;
m_lastResizeHoverType = resizeType; m_lastResizeHoverType = resizeType;
s_resizeCursorImage.SetActive(true); s_resizeCursorObj.SetActive(true);
// set the rotation for the resize icon // set the rotation for the resize icon
float iconRotation = 0f; float iconRotation = 0f;
@ -239,9 +245,9 @@ namespace UnityExplorer.UI
iconRotation = 135f; break; iconRotation = 135f; break;
} }
Quaternion rot = s_resizeCursorImage.transform.rotation; Quaternion rot = s_resizeCursorObj.transform.rotation;
rot.eulerAngles = new Vector3(0, 0, iconRotation); rot.eulerAngles = new Vector3(0, 0, iconRotation);
s_resizeCursorImage.transform.rotation = rot; s_resizeCursorObj.transform.rotation = rot;
UpdateHoverImagePos(); UpdateHoverImagePos();
} }
@ -250,13 +256,13 @@ namespace UnityExplorer.UI
private void UpdateHoverImagePos() private void UpdateHoverImagePos()
{ {
RectTransform t = UIManager.CanvasRoot.GetComponent<RectTransform>(); RectTransform t = UIManager.CanvasRoot.GetComponent<RectTransform>();
s_resizeCursorImage.transform.localPosition = t.InverseTransformPoint(InputManager.MousePosition); s_resizeCursorObj.transform.localPosition = t.InverseTransformPoint(InputManager.MousePosition);
} }
public void OnHoverResizeEnd() public void OnHoverResizeEnd()
{ {
WasHoveringResize = false; WasHoveringResize = false;
s_resizeCursorImage.SetActive(false); s_resizeCursorObj.SetActive(false);
} }
public void OnBeginResize(ResizeTypes resizeType) public void OnBeginResize(ResizeTypes resizeType)
@ -321,19 +327,18 @@ namespace UnityExplorer.UI
{ {
try try
{ {
var sprite = UIManager.ResizeCursor; s_resizeCursorObj = UIFactory.CreateLabel(UIManager.CanvasRoot.gameObject, TextAnchor.MiddleCenter);
s_resizeCursorImage = new GameObject("ResizeCursorImage"); var text = s_resizeCursorObj.GetComponent<Text>();
s_resizeCursorImage.transform.SetParent(UIManager.CanvasRoot.transform); text.text = "↔";
text.fontSize = 35;
text.color = Color.white;
Image image = s_resizeCursorImage.AddComponent<Image>(); RectTransform rect = s_resizeCursorObj.transform.GetComponent<RectTransform>();
image.sprite = sprite; rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 64);
image.material = Graphic.defaultGraphicMaterial; rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 64);
RectTransform rect = image.transform.GetComponent<RectTransform>();
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 32);
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 32);
s_resizeCursorImage.SetActive(false); s_resizeCursorObj.SetActive(false);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -295,8 +295,8 @@ namespace UnityExplorer.UI.Main
mainGroup.spacing = 5; mainGroup.spacing = 5;
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
ConstructTopArea(); ConstructTopArea();
@ -308,9 +308,9 @@ namespace UnityExplorer.UI.Main
var topAreaObj = UIFactory.CreateVerticalGroup(Content, new Color(0.15f, 0.15f, 0.15f)); var topAreaObj = UIFactory.CreateVerticalGroup(Content, new Color(0.15f, 0.15f, 0.15f));
var topGroup = topAreaObj.GetComponent<VerticalLayoutGroup>(); var topGroup = topAreaObj.GetComponent<VerticalLayoutGroup>();
topGroup.childForceExpandHeight = false; topGroup.childForceExpandHeight = false;
topGroup.childControlHeight = true; topGroup.SetChildControlHeight(true);
topGroup.childForceExpandWidth = true; topGroup.childForceExpandWidth = true;
topGroup.childControlWidth = true; topGroup.SetChildControlWidth(true);
topGroup.padding.top = 5; topGroup.padding.top = 5;
topGroup.padding.left = 5; topGroup.padding.left = 5;
topGroup.padding.right = 5; topGroup.padding.right = 5;
@ -330,9 +330,9 @@ namespace UnityExplorer.UI.Main
var optionsGroupObj = UIFactory.CreateVerticalGroup(topAreaObj, new Color(0.1f, 0.1f, 0.1f)); var optionsGroupObj = UIFactory.CreateVerticalGroup(topAreaObj, new Color(0.1f, 0.1f, 0.1f));
var optionsGroup = optionsGroupObj.GetComponent<VerticalLayoutGroup>(); var optionsGroup = optionsGroupObj.GetComponent<VerticalLayoutGroup>();
optionsGroup.childForceExpandHeight = false; optionsGroup.childForceExpandHeight = false;
optionsGroup.childControlHeight = true; optionsGroup.SetChildControlHeight(true);
optionsGroup.childForceExpandWidth = true; optionsGroup.childForceExpandWidth = true;
optionsGroup.childControlWidth = true; optionsGroup.SetChildControlWidth(true);
optionsGroup.spacing = 10; optionsGroup.spacing = 10;
optionsGroup.padding.top = 4; optionsGroup.padding.top = 4;
optionsGroup.padding.right = 4; optionsGroup.padding.right = 4;
@ -348,9 +348,9 @@ namespace UnityExplorer.UI.Main
var contextRowObj = UIFactory.CreateHorizontalGroup(optionsGroupObj, new Color(1, 1, 1, 0)); var contextRowObj = UIFactory.CreateHorizontalGroup(optionsGroupObj, new Color(1, 1, 1, 0));
var contextGroup = contextRowObj.GetComponent<HorizontalLayoutGroup>(); var contextGroup = contextRowObj.GetComponent<HorizontalLayoutGroup>();
contextGroup.childForceExpandWidth = false; contextGroup.childForceExpandWidth = false;
contextGroup.childControlWidth = true; contextGroup.SetChildControlWidth(true);
contextGroup.childForceExpandHeight = false; contextGroup.childForceExpandHeight = false;
contextGroup.childControlHeight = true; contextGroup.SetChildControlHeight(true);
contextGroup.spacing = 3; contextGroup.spacing = 3;
var contextLayout = contextRowObj.AddComponent<LayoutElement>(); var contextLayout = contextRowObj.AddComponent<LayoutElement>();
contextLayout.minHeight = 25; contextLayout.minHeight = 25;
@ -402,9 +402,9 @@ namespace UnityExplorer.UI.Main
var nameRowObj = UIFactory.CreateHorizontalGroup(optionsGroupObj, new Color(1, 1, 1, 0)); var nameRowObj = UIFactory.CreateHorizontalGroup(optionsGroupObj, new Color(1, 1, 1, 0));
var nameRowGroup = nameRowObj.GetComponent<HorizontalLayoutGroup>(); var nameRowGroup = nameRowObj.GetComponent<HorizontalLayoutGroup>();
nameRowGroup.childForceExpandWidth = true; nameRowGroup.childForceExpandWidth = true;
nameRowGroup.childControlWidth = true; nameRowGroup.SetChildControlWidth(true);
nameRowGroup.childForceExpandHeight = false; nameRowGroup.childForceExpandHeight = false;
nameRowGroup.childControlHeight = true; nameRowGroup.SetChildControlHeight(true);
var nameRowLayout = nameRowObj.AddComponent<LayoutElement>(); var nameRowLayout = nameRowObj.AddComponent<LayoutElement>();
nameRowLayout.minHeight = 25; nameRowLayout.minHeight = 25;
nameRowLayout.flexibleHeight = 0; nameRowLayout.flexibleHeight = 0;
@ -431,9 +431,9 @@ namespace UnityExplorer.UI.Main
m_extraFilterRow.SetActive(false); m_extraFilterRow.SetActive(false);
var extraGroup = m_extraFilterRow.GetComponent<HorizontalLayoutGroup>(); var extraGroup = m_extraFilterRow.GetComponent<HorizontalLayoutGroup>();
extraGroup.childForceExpandHeight = true; extraGroup.childForceExpandHeight = true;
extraGroup.childControlHeight = true; extraGroup.SetChildControlHeight(true);
extraGroup.childForceExpandWidth = false; extraGroup.childForceExpandWidth = false;
extraGroup.childControlWidth = true; extraGroup.SetChildControlWidth(true);
var filterRowLayout = m_extraFilterRow.AddComponent<LayoutElement>(); var filterRowLayout = m_extraFilterRow.AddComponent<LayoutElement>();
filterRowLayout.minHeight = 25; filterRowLayout.minHeight = 25;
filterRowLayout.flexibleHeight = 0; filterRowLayout.flexibleHeight = 0;
@ -543,8 +543,8 @@ namespace UnityExplorer.UI.Main
var resultGroup = resultGroupObj.GetComponent<VerticalLayoutGroup>(); var resultGroup = resultGroupObj.GetComponent<VerticalLayoutGroup>();
resultGroup.childForceExpandHeight = false; resultGroup.childForceExpandHeight = false;
resultGroup.childForceExpandWidth = true; resultGroup.childForceExpandWidth = true;
resultGroup.childControlHeight = true; resultGroup.SetChildControlHeight(true);
resultGroup.childControlWidth = true; resultGroup.SetChildControlWidth(true);
resultGroup.spacing = 5; resultGroup.spacing = 5;
resultGroup.padding.top = 5; resultGroup.padding.top = 5;
resultGroup.padding.right = 5; resultGroup.padding.right = 5;
@ -568,7 +568,7 @@ namespace UnityExplorer.UI.Main
var contentGroup = m_resultListContent.GetComponent<VerticalLayoutGroup>(); var contentGroup = m_resultListContent.GetComponent<VerticalLayoutGroup>();
contentGroup.spacing = 2; contentGroup.spacing = 2;
contentGroup.childForceExpandHeight = false; contentGroup.childForceExpandHeight = false;
contentGroup.childControlHeight = true; contentGroup.SetChildControlHeight(true);
} }
internal void AddResultButton() internal void AddResultButton()
@ -578,9 +578,9 @@ namespace UnityExplorer.UI.Main
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_resultListContent, new Color(0.1f, 0.1f, 0.1f)); GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_resultListContent, new Color(0.1f, 0.1f, 0.1f));
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
btnGroup.childForceExpandWidth = true; btnGroup.childForceExpandWidth = true;
btnGroup.childControlWidth = true; btnGroup.SetChildControlWidth(true);
btnGroup.childForceExpandHeight = false; btnGroup.childForceExpandHeight = false;
btnGroup.childControlHeight = true; btnGroup.SetChildControlHeight(true);
btnGroup.padding.top = 1; btnGroup.padding.top = 1;
btnGroup.padding.left = 1; btnGroup.padding.left = 1;
btnGroup.padding.right = 1; btnGroup.padding.right = 1;

View File

@ -176,8 +176,8 @@ namespace UnityExplorer.UI.Reusable
HorizontalLayoutGroup mainGroup = m_pageUIHolder.GetComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup mainGroup = m_pageUIHolder.GetComponent<HorizontalLayoutGroup>();
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = false; mainGroup.childForceExpandWidth = false;
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
LayoutElement mainLayout = m_pageUIHolder.AddComponent<LayoutElement>(); LayoutElement mainLayout = m_pageUIHolder.AddComponent<LayoutElement>();
mainLayout.minHeight = 25; mainLayout.minHeight = 25;

View File

@ -97,8 +97,8 @@ namespace UnityExplorer.UI
img.color = Color.white; img.color = Color.white;
VerticalLayoutGroup group = panelObj.AddComponent<VerticalLayoutGroup>(); VerticalLayoutGroup group = panelObj.AddComponent<VerticalLayoutGroup>();
group.childControlHeight = true; group.SetChildControlHeight(true);
group.childControlWidth = true; group.SetChildControlWidth(true);
group.childForceExpandHeight = true; group.childForceExpandHeight = true;
group.childForceExpandWidth = true; group.childForceExpandWidth = true;
@ -115,8 +115,8 @@ namespace UnityExplorer.UI
group2.padding.bottom = 3; group2.padding.bottom = 3;
group2.padding.top = 3; group2.padding.top = 3;
group2.spacing = 3; group2.spacing = 3;
group2.childControlHeight = true; group2.SetChildControlHeight(true);
group2.childControlWidth = true; group2.SetChildControlWidth(true);
group2.childForceExpandHeight = false; group2.childForceExpandHeight = false;
group2.childForceExpandWidth = true; group2.childForceExpandWidth = true;
@ -151,8 +151,8 @@ namespace UnityExplorer.UI
VerticalLayoutGroup horiGroup = groupObj.AddComponent<VerticalLayoutGroup>(); VerticalLayoutGroup horiGroup = groupObj.AddComponent<VerticalLayoutGroup>();
horiGroup.childAlignment = TextAnchor.UpperLeft; horiGroup.childAlignment = TextAnchor.UpperLeft;
horiGroup.childControlWidth = true; horiGroup.SetChildControlWidth(true);
horiGroup.childControlHeight = true; horiGroup.SetChildControlHeight(true);
Image image = groupObj.AddComponent<Image>(); Image image = groupObj.AddComponent<Image>();
if (color != default) if (color != default)
@ -173,8 +173,8 @@ namespace UnityExplorer.UI
HorizontalLayoutGroup horiGroup = groupObj.AddComponent<HorizontalLayoutGroup>(); HorizontalLayoutGroup horiGroup = groupObj.AddComponent<HorizontalLayoutGroup>();
horiGroup.childAlignment = TextAnchor.UpperLeft; horiGroup.childAlignment = TextAnchor.UpperLeft;
horiGroup.childControlWidth = true; horiGroup.SetChildControlWidth(true);
horiGroup.childControlHeight = true; horiGroup.SetChildControlHeight(true);
Image image = groupObj.AddComponent<Image>(); Image image = groupObj.AddComponent<Image>();
if (color != default) if (color != default)
@ -423,8 +423,8 @@ namespace UnityExplorer.UI
mainInput.colors = mainColors; mainInput.colors = mainColors;
VerticalLayoutGroup mainGroup = mainObj.AddComponent<VerticalLayoutGroup>(); VerticalLayoutGroup mainGroup = mainObj.AddComponent<VerticalLayoutGroup>();
mainGroup.childControlHeight = true; mainGroup.SetChildControlHeight(true);
mainGroup.childControlWidth = true; mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandWidth = true; mainGroup.childForceExpandWidth = true;
mainGroup.childForceExpandHeight = true; mainGroup.childForceExpandHeight = true;
@ -655,9 +655,9 @@ namespace UnityExplorer.UI
var contentGroup = content.AddComponent<VerticalLayoutGroup>(); var contentGroup = content.AddComponent<VerticalLayoutGroup>();
contentGroup.childForceExpandHeight = true; contentGroup.childForceExpandHeight = true;
contentGroup.childControlHeight = true; contentGroup.SetChildControlHeight(true);
contentGroup.childForceExpandWidth = true; contentGroup.childForceExpandWidth = true;
contentGroup.childControlWidth = true; contentGroup.SetChildControlWidth(true);
contentGroup.padding.left = 5; contentGroup.padding.left = 5;
contentGroup.padding.right = 5; contentGroup.padding.right = 5;
contentGroup.padding.top = 5; contentGroup.padding.top = 5;
@ -668,7 +668,7 @@ namespace UnityExplorer.UI
var scrollbarLayout = scrollBarObj.AddComponent<VerticalLayoutGroup>(); var scrollbarLayout = scrollBarObj.AddComponent<VerticalLayoutGroup>();
scrollbarLayout.childForceExpandHeight = true; scrollbarLayout.childForceExpandHeight = true;
scrollbarLayout.childControlHeight = true; scrollbarLayout.SetChildControlHeight(true);
RectTransform scrollBarRect = scrollBarObj.GetComponent<RectTransform>(); RectTransform scrollBarRect = scrollBarObj.GetComponent<RectTransform>();
scrollBarRect.anchorMin = new Vector2(1.0f, 0.0f); scrollBarRect.anchorMin = new Vector2(1.0f, 0.0f);

View File

@ -20,7 +20,7 @@ namespace UnityExplorer.UI
internal static Font ConsoleFont { get; private set; } internal static Font ConsoleFont { get; private set; }
internal static Sprite ResizeCursor { get; private set; } //internal static Sprite ResizeCursor { get; private set; }
internal static Shader BackupShader { get; private set; } internal static Shader BackupShader { get; private set; }
public static bool ShowMenu public static bool ShowMenu
@ -76,6 +76,33 @@ namespace UnityExplorer.UI
Canvas.ForceUpdateCanvases(); Canvas.ForceUpdateCanvases();
} }
private static GameObject CreateRootCanvas()
{
GameObject rootObj = new GameObject("ExplorerCanvas");
UnityEngine.Object.DontDestroyOnLoad(rootObj);
rootObj.layer = 5;
CanvasRoot = rootObj;
CanvasRoot.transform.position = new Vector3(0f, 0f, 1f);
EventSys = rootObj.AddComponent<EventSystem>();
InputManager.AddUIModule();
Canvas canvas = rootObj.AddComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceCamera;
canvas.referencePixelsPerUnit = 100;
canvas.sortingOrder = 999;
//canvas.pixelPerfect = false;
CanvasScaler scaler = rootObj.AddComponent<CanvasScaler>();
scaler.referenceResolution = new Vector2(1920, 1080);
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand;
rootObj.AddComponent<GraphicRaycaster>();
return rootObj;
}
private static void SetShowMenu(bool show) private static void SetShowMenu(bool show)
{ {
if (s_showMenu == show) if (s_showMenu == show)
@ -96,12 +123,6 @@ namespace UnityExplorer.UI
CursorUnlocker.UpdateCursorControl(); CursorUnlocker.UpdateCursorControl();
} }
//public static void OnSceneChange()
//{
// SceneExplorer.Instance?.OnSceneChange();
// SearchPage.Instance?.OnSceneChange();
//}
public static void Update() public static void Update()
{ {
if (InputManager.GetKeyDown(ExplorerConfig.Instance.Main_Menu_Toggle)) if (InputManager.GetKeyDown(ExplorerConfig.Instance.Main_Menu_Toggle))
@ -151,24 +172,6 @@ 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())
{
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 void LoadBundle() private static void LoadBundle()
{ {
AssetBundle bundle = null; AssetBundle bundle = null;
@ -176,10 +179,12 @@ namespace UnityExplorer.UI
try try
{ {
bundle = LoadExplorerUi("modern"); bundle = LoadExplorerUi("modern");
if (bundle == null)
throw new Exception();
} }
catch catch
{ {
ExplorerCore.Log("Failed to load modern ExplorerUI Bundle, falling back to legacy"); ExplorerCore.Log("Failed to load Unity 2017 ExplorerUI Bundle, falling back to legacy");
try try
{ {
@ -194,6 +199,7 @@ namespace UnityExplorer.UI
if (bundle == null) if (bundle == null)
{ {
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!"); ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
return; return;
} }
@ -206,38 +212,29 @@ namespace UnityExplorer.UI
Graphic.defaultGraphicMaterial.shader = BackupShader; Graphic.defaultGraphicMaterial.shader = BackupShader;
} }
ResizeCursor = bundle.LoadAsset<Sprite>("cursor"); //ResizeCursor = bundle.LoadAsset<Sprite>("cursor");
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA"); ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
ExplorerCore.Log("Loaded UI bundle"); ExplorerCore.Log("Loaded UI bundle");
} }
private static GameObject CreateRootCanvas() private static AssetBundle LoadExplorerUi(string id)
{ {
GameObject rootObj = new GameObject("ExplorerCanvas"); var data = ReadFully(typeof(ExplorerCore).Assembly.GetManifestResourceStream($"UnityExplorer.Resources.explorerui.{id}.bundle"));
UnityEngine.Object.DontDestroyOnLoad(rootObj); return AssetBundle.LoadFromMemory(data);
rootObj.layer = 5; }
CanvasRoot = rootObj; private static byte[] ReadFully(this Stream input)
CanvasRoot.transform.position = new Vector3(0f, 0f, 1f); {
using (var ms = new MemoryStream())
EventSys = rootObj.AddComponent<EventSystem>(); {
InputManager.AddUIModule(); byte[] buffer = new byte[81920];
int read;
Canvas canvas = rootObj.AddComponent<Canvas>(); while ((read = input.Read(buffer, 0, buffer.Length)) != 0)
canvas.renderMode = RenderMode.ScreenSpaceCamera; ms.Write(buffer, 0, read);
canvas.referencePixelsPerUnit = 100; return ms.ToArray();
canvas.sortingOrder = 999; }
//canvas.pixelPerfect = false;
CanvasScaler scaler = rootObj.AddComponent<CanvasScaler>();
scaler.referenceResolution = new Vector2(1920, 1080);
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand;
rootObj.AddComponent<GraphicRaycaster>();
return rootObj;
} }
} }
} }

View File

@ -24,10 +24,6 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
<RootNamespace>UnityExplorer</RootNamespace> <RootNamespace>UnityExplorer</RootNamespace>
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->
<BIECppGameFolder>E:\source\Unity Projects\Test\_BUILD</BIECppGameFolder>
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
<MLCppGameFolder>E:\source\Unity Projects\Test\_BUILD</MLCppGameFolder>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
@ -161,106 +157,71 @@
<!-- MelonLoader Il2Cpp refs --> <!-- MelonLoader Il2Cpp refs -->
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='true|true'"> <ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='true|true'">
<Reference Include="MelonLoader"> <Reference Include="MelonLoader">
<HintPath>$(MLCppGameFolder)\MelonLoader\MelonLoader.dll</HintPath> <HintPath>..\lib\MelonLoader.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnhollowerBaseLib">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\UnhollowerBaseLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Il2Cppmscorlib">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\Il2Cppmscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Il2CppSystem.Core">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\Il2CppSystem.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>$(MLCppGameFolder)\MelonLoader\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<!-- BepInEx Il2Cpp refs --> <!-- BepInEx Il2Cpp refs -->
<ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='false|true'"> <ItemGroup Condition="'$(IsMelonLoader)|$(IsCpp)'=='false|true'">
<Reference Include="BepInEx"> <Reference Include="BepInEx">
<HintPath>$(BIECppGameFolder)\BepInEx\core\BepInEx.Core.dll</HintPath> <HintPath>..\lib\BepInEx.Core.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="0Harmony"> <Reference Include="0Harmony">
<HintPath>$(BIECppGameFolder)\BepInEx\core\0Harmony.dll</HintPath> <HintPath>..\lib\0Harmony.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="BepInEx.IL2CPP"> <Reference Include="BepInEx.IL2CPP">
<HintPath>$(BIECppGameFolder)\BepInEx\core\BepInEx.IL2CPP.dll</HintPath> <HintPath>..\lib\BepInEx.IL2CPP.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
</ItemGroup>
<!-- Unhollowed Il2Cpp refs -->
<ItemGroup Condition="'$(IsCpp)'=='true'">
<Reference Include="UnhollowerBaseLib"> <Reference Include="UnhollowerBaseLib">
<HintPath>$(BIECppGameFolder)\BepInEx\core\UnhollowerBaseLib.dll</HintPath> <HintPath>..\lib\UnhollowerBaseLib.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="Il2Cppmscorlib"> <Reference Include="Il2Cppmscorlib">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\Il2Cppmscorlib.dll</HintPath> <HintPath>..\lib\unhollowed\Il2Cppmscorlib.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="Il2CppSystem.Core"> <Reference Include="Il2CppSystem.Core">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\Il2CppSystem.Core.dll</HintPath> <HintPath>..\lib\unhollowed\Il2CppSystem.Core.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\UnityEngine.dll</HintPath> <HintPath>..\lib\unhollowed\UnityEngine.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.CoreModule"> <Reference Include="UnityEngine.CoreModule">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\UnityEngine.CoreModule.dll</HintPath> <HintPath>..\lib\unhollowed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.PhysicsModule"> <Reference Include="UnityEngine.PhysicsModule">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\UnityEngine.PhysicsModule.dll</HintPath> <HintPath>..\lib\unhollowed\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.TextRenderingModule"> <Reference Include="UnityEngine.TextRenderingModule">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\UnityEngine.TextRenderingModule.dll</HintPath> <HintPath>..\lib\unhollowed\UnityEngine.TextRenderingModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.UI"> <Reference Include="UnityEngine.UI">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\UnityEngine.UI.dll</HintPath> <HintPath>..\lib\unhollowed\UnityEngine.UI.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.UIModule"> <Reference Include="UnityEngine.UIModule">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\UnityEngine.UIModule.dll</HintPath> <HintPath>..\lib\unhollowed\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine.IMGUIModule"> <Reference Include="UnityEngine.IMGUIModule">
<HintPath>$(BIECppGameFolder)\BepInEx\unhollowed\UnityEngine.IMGUIModule.dll</HintPath> <HintPath>..\lib\unhollowed\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Core\CSharp\DummyBehaviour.cs" />
<Compile Include="Core\Runtime\Il2Cpp\Il2CppCoroutine.cs" />
<Compile Include="Loader\ExplorerBepIn6Plugin.cs" /> <Compile Include="Loader\ExplorerBepIn6Plugin.cs" />
<Compile Include="Loader\ExplorerStandalone.cs" /> <Compile Include="Loader\ExplorerStandalone.cs" />
<Compile Include="Core\Runtime\Il2Cpp\Il2CppReflection.cs" /> <Compile Include="Core\Runtime\Il2Cpp\Il2CppReflection.cs" />