* 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)
This commit is contained in:
Sinai 2021-03-26 19:49:53 +11:00
parent 604c499822
commit 46f35129c5
36 changed files with 442 additions and 351 deletions

Binary file not shown.

Binary file not shown.

View File

@ -5,6 +5,8 @@ using IniParser;
using IniParser.Parser;
using UnityExplorer.UI;
using System.Globalization;
using UnityExplorer.Core.Inspectors;
using UnityExplorer.UI.Main;
namespace UnityExplorer.Core.Config
{
@ -17,13 +19,6 @@ namespace UnityExplorer.Core.Config
internal static CultureInfo _enCulture = new CultureInfo("en-US");
static ExplorerConfig()
{
_parser.Configuration.CommentString = "#";
PanelDragger.OnFinishResize += PanelDragger_OnFinishResize;
}
// Actual configs
public KeyCode Main_Menu_Toggle = KeyCode.F7;
public bool Force_Unlock_Mouse = true;
@ -32,6 +27,9 @@ namespace UnityExplorer.Core.Config
public bool Log_Unity_Debug = false;
public bool Hide_On_Startup = false;
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";
@ -45,6 +43,12 @@ namespace UnityExplorer.Core.Config
public static void OnLoad()
{
Instance = new ExplorerConfig();
_parser.Configuration.CommentString = "#";
PanelDragger.OnFinishResize += PanelDragger_OnFinishResize;
SceneExplorer.OnToggleShow += SceneExplorer_OnToggleShow;
DebugConsole.OnToggleShow += DebugConsole_OnToggleShow;
MainMenu.OnActiveTabChanged += MainMenu_OnActiveTabChanged;
if (LoadSettings())
return;
@ -86,6 +90,15 @@ namespace UnityExplorer.Core.Config
case nameof(Window_Anchors):
Instance.Window_Anchors = config.Value;
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(Hide_On_Startup), Instance.Hide_On_Startup.ToString());
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))
Directory.CreateDirectory(ExplorerCore.Loader.ConfigFolder);
@ -113,6 +129,24 @@ namespace UnityExplorer.Core.Config
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 ============== //
private static void PanelDragger_OnFinishResize()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,6 +11,7 @@ using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using System.Collections;
using UnityEngine.UI;
namespace UnityExplorer.Core.Runtime.Il2Cpp
{
@ -107,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)
{
@ -118,6 +119,9 @@ public static class UnityEventExtensions
{
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

View File

@ -7,6 +7,7 @@ using System.Reflection;
using System.Text;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityExplorer.Core;
using UnityExplorer.Core.CSharp;
@ -63,6 +64,26 @@ public static class MonoExtensions
{
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

View File

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

View File

@ -17,7 +17,7 @@ namespace UnityExplorer
public class ExplorerCore
{
public const string NAME = "UnityExplorer";
public const string VERSION = "3.2.9";
public const string VERSION = "3.2.10";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";

Binary file not shown.

View File

@ -269,8 +269,8 @@ namespace UnityExplorer.UI.Main.CSConsole
mainRect.offsetMax = Vector2.zero;
var mainGroup = content.GetComponent<VerticalLayoutGroup>();
mainGroup.childControlHeight = false;
mainGroup.childControlWidth = true;
mainGroup.SetChildControlHeight(false);
mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = false;
mainGroup.childForceExpandWidth = true;

View File

@ -463,8 +463,8 @@ The following helper methods are available:
mainLayout.flexibleHeight = 9000;
var mainGroup = Content.AddComponent<VerticalLayoutGroup>();
mainGroup.childControlHeight = true;
mainGroup.childControlWidth = true;
mainGroup.SetChildControlHeight(true);
mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true;
@ -485,8 +485,8 @@ The following helper methods are available:
topBarGroup.spacing = 10;
topBarGroup.childForceExpandHeight = true;
topBarGroup.childForceExpandWidth = true;
topBarGroup.childControlWidth = true;
topBarGroup.childControlHeight = true;
topBarGroup.SetChildControlWidth(true);
topBarGroup.SetChildControlHeight(true);
topBarGroup.childAlignment = TextAnchor.LowerCenter;
var topBarLabel = UIFactory.CreateLabel(topBarObj, TextAnchor.MiddleLeft);

View File

@ -14,7 +14,7 @@ namespace UnityExplorer.UI.Main
{
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;
internal static StreamWriter s_streamWriter;
@ -32,9 +32,13 @@ namespace UnityExplorer.UI.Main
public DebugConsole(GameObject parent)
{
Instance = this;
LogUnity = ExplorerConfig.Instance.Log_Unity_Debug;
ConstructUI(parent);
if (ExplorerConfig.Instance.DebugConsole_Hidden)
ToggleShow();
// append messages that logged before we were set up
string preAppend = "";
for (int i = s_preInitMessages.Count - 1; i >= 0; i--)
@ -48,9 +52,6 @@ namespace UnityExplorer.UI.Main
// set up IO
//if (!SaveToDisk)
// return;
var path = ExplorerCore.EXPLORER_FOLDER + @"\Logs";
if (!Directory.Exists(path))
@ -80,6 +81,34 @@ namespace UnityExplorer.UI.Main
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)
{
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 mainGroup = mainObj.GetComponent<VerticalLayoutGroup>();
mainGroup.childControlHeight = true;
mainGroup.childControlWidth = true;
mainGroup.SetChildControlHeight(true);
mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true;
@ -140,23 +169,23 @@ namespace UnityExplorer.UI.Main
var mask = mainObj.AddComponent<Mask>();
mask.showMaskGraphic = true;
var mainLayout = mainObj.AddComponent<LayoutElement>();
mainLayout.minHeight = 190;
mainLayout.flexibleHeight = 0;
m_mainLayout = mainObj.AddComponent<LayoutElement>();
m_mainLayout.minHeight = 190;
m_mainLayout.flexibleHeight = 0;
#region LOG AREA
var logAreaObj = UIFactory.CreateHorizontalGroup(mainObj);
var logAreaGroup = logAreaObj.GetComponent<HorizontalLayoutGroup>();
logAreaGroup.childControlHeight = true;
logAreaGroup.childControlWidth = true;
m_logAreaObj = UIFactory.CreateHorizontalGroup(mainObj);
var logAreaGroup = m_logAreaObj.GetComponent<HorizontalLayoutGroup>();
logAreaGroup.SetChildControlHeight(true);
logAreaGroup.SetChildControlWidth(true);
logAreaGroup.childForceExpandHeight = true;
logAreaGroup.childForceExpandWidth = true;
var logAreaLayout = logAreaObj.AddComponent<LayoutElement>();
var logAreaLayout = m_logAreaObj.AddComponent<LayoutElement>();
logAreaLayout.preferredHeight = 190;
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.readOnly = true;
@ -179,8 +208,8 @@ namespace UnityExplorer.UI.Main
bottomGroup.spacing = 10;
bottomGroup.childForceExpandHeight = true;
bottomGroup.childForceExpandWidth = false;
bottomGroup.childControlWidth = true;
bottomGroup.childControlHeight = true;
bottomGroup.SetChildControlWidth(true);
bottomGroup.SetChildControlHeight(true);
bottomGroup.childAlignment = TextAnchor.MiddleLeft;
// Debug Console label
@ -198,26 +227,15 @@ namespace UnityExplorer.UI.Main
var hideButtonObj = UIFactory.CreateButton(bottomBarObj);
var hideBtnText = hideButtonObj.GetComponentInChildren<Text>();
hideBtnText.text = "Hide";
m_hideBtnText = hideButtonObj.GetComponentInChildren<Text>();
m_hideBtnText.text = "Hide";
var hideButton = hideButtonObj.GetComponent<Button>();
hideButton.onClick.AddListener(HideCallback);
void HideCallback()
{
if (logAreaObj.activeSelf)
{
logAreaObj.SetActive(false);
hideBtnText.text = "Show";
mainLayout.minHeight = 30;
}
else
{
logAreaObj.SetActive(true);
hideBtnText.text = "Hide";
mainLayout.minHeight = 190;
}
ToggleShow();
}
var hideBtnColors = hideButton.colors;

View File

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

View File

@ -43,8 +43,8 @@ namespace UnityExplorer.UI.Main.Home
var mainGroup = mainObj.GetComponent<VerticalLayoutGroup>();
mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true;
mainGroup.childControlHeight = true;
mainGroup.childControlWidth = true;
mainGroup.SetChildControlHeight(true);
mainGroup.SetChildControlWidth(true);
mainGroup.spacing = 4;
mainGroup.padding.left = 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 topRowGroup = topRowObj.GetComponent<HorizontalLayoutGroup>();
topRowGroup.childForceExpandWidth = false;
topRowGroup.childControlWidth = true;
topRowGroup.SetChildControlWidth(true);
topRowGroup.childForceExpandHeight = true;
topRowGroup.childControlHeight = true;
topRowGroup.SetChildControlHeight(true);
topRowGroup.spacing = 15;
var inspectorTitle = UIFactory.CreateLabel(topRowObj, TextAnchor.MiddleLeft);
@ -87,15 +87,15 @@ namespace UnityExplorer.UI.Main.Home
var inspectorGroup = m_inspectorContent.GetComponent<VerticalLayoutGroup>();
inspectorGroup.childForceExpandHeight = true;
inspectorGroup.childForceExpandWidth = true;
inspectorGroup.childControlHeight = true;
inspectorGroup.childControlWidth = true;
inspectorGroup.SetChildControlHeight(true);
inspectorGroup.SetChildControlWidth(true);
m_inspectorContent = UIFactory.CreateVerticalGroup(mainObj, new Color(0.1f, 0.1f, 0.1f));
var contentGroup = m_inspectorContent.GetComponent<VerticalLayoutGroup>();
contentGroup.childForceExpandHeight = true;
contentGroup.childForceExpandWidth = true;
contentGroup.childControlHeight = true;
contentGroup.childControlWidth = true;
contentGroup.SetChildControlHeight(true);
contentGroup.SetChildControlWidth(true);
contentGroup.padding.top = 2;
contentGroup.padding.left = 2;
contentGroup.padding.right = 2;
@ -114,8 +114,8 @@ namespace UnityExplorer.UI.Main.Home
var invisGroup = invisObj.GetComponent<HorizontalLayoutGroup>();
invisGroup.childForceExpandWidth = false;
invisGroup.childForceExpandHeight = false;
invisGroup.childControlWidth = true;
invisGroup.childControlHeight = true;
invisGroup.SetChildControlWidth(true);
invisGroup.SetChildControlHeight(true);
invisGroup.padding.top = 2;
invisGroup.padding.bottom = 2;
invisGroup.padding.left = 2;

View File

@ -143,7 +143,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var vertGroup = vertGroupObj.GetComponent<VerticalLayoutGroup>();
vertGroup.childForceExpandHeight = true;
vertGroup.childForceExpandWidth = false;
vertGroup.childControlWidth = true;
vertGroup.SetChildControlWidth(true);
vertGroup.spacing = 5;
var vertLayout = vertGroupObj.AddComponent<LayoutElement>();
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));
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
btnGroup.childForceExpandWidth = true;
btnGroup.childControlWidth = true;
btnGroup.SetChildControlWidth(true);
btnGroup.childForceExpandHeight = false;
btnGroup.childControlHeight = true;
btnGroup.SetChildControlHeight(true);
LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>();
btnLayout.flexibleWidth = 320;
btnLayout.minHeight = 25;

View File

@ -145,7 +145,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var vertGroup = vertGroupObj.GetComponent<VerticalLayoutGroup>();
vertGroup.childForceExpandHeight = true;
vertGroup.childForceExpandWidth = false;
vertGroup.childControlWidth = true;
vertGroup.SetChildControlWidth(true);
vertGroup.spacing = 5;
var vertLayout = vertGroupObj.AddComponent<LayoutElement>();
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));
HorizontalLayoutGroup group = groupObj.GetComponent<HorizontalLayoutGroup>();
group.childForceExpandWidth = true;
group.childControlWidth = true;
group.SetChildControlWidth(true);
group.childForceExpandHeight = false;
group.childControlHeight = true;
group.SetChildControlHeight(true);
group.childAlignment = TextAnchor.MiddleLeft;
LayoutElement groupLayout = groupObj.AddComponent<LayoutElement>();
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 controlsGroup = controlsObj.GetComponent<VerticalLayoutGroup>();
controlsGroup.childForceExpandWidth = false;
controlsGroup.childControlWidth = true;
controlsGroup.SetChildControlWidth(true);
controlsGroup.childForceExpandHeight = false;
controlsGroup.spacing = 5;
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 topRowGroup = topRow.GetComponent<HorizontalLayoutGroup>();
topRowGroup.childForceExpandWidth = false;
topRowGroup.childControlWidth = true;
topRowGroup.SetChildControlWidth(true);
topRowGroup.childForceExpandHeight = false;
topRowGroup.childControlHeight = true;
topRowGroup.SetChildControlHeight(true);
topRowGroup.spacing = 5;
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 contentGroup = contentObj.GetComponent<VerticalLayoutGroup>();
contentGroup.childForceExpandHeight = false;
contentGroup.childControlHeight = true;
contentGroup.SetChildControlHeight(true);
contentGroup.spacing = 5;
contentGroup.childForceExpandWidth = true;
contentGroup.childControlWidth = true;
contentGroup.SetChildControlWidth(true);
// ~~ add hide button callback now that we have scroll reference ~~
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 setParentGroup = setParentGroupObj.GetComponent<HorizontalLayoutGroup>();
setParentGroup.childForceExpandHeight = false;
setParentGroup.childControlHeight = true;
setParentGroup.SetChildControlHeight(true);
setParentGroup.childForceExpandWidth = false;
setParentGroup.childControlWidth = true;
setParentGroup.SetChildControlWidth(true);
setParentGroup.spacing = 5;
var setParentLayout = setParentGroupObj.AddComponent<LayoutElement>();
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 topGroup = topBarObj.GetComponent<HorizontalLayoutGroup>();
topGroup.childForceExpandWidth = false;
topGroup.childControlWidth = true;
topGroup.SetChildControlWidth(true);
topGroup.childForceExpandHeight = false;
topGroup.childControlHeight = true;
topGroup.SetChildControlHeight(true);
topGroup.spacing = 5;
var topLayout = topBarObj.AddComponent<LayoutElement>();
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 rowGroup = rowObject.GetComponent<HorizontalLayoutGroup>();
rowGroup.childForceExpandWidth = false;
rowGroup.childControlWidth = true;
rowGroup.SetChildControlWidth(true);
rowGroup.childForceExpandHeight = false;
rowGroup.childControlHeight = true;
rowGroup.SetChildControlHeight(true);
rowGroup.spacing = 5;
var rowLayout = rowObject.AddComponent<LayoutElement>();
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 inputHolderGroup = inputHolder.GetComponent<VerticalLayoutGroup>();
inputHolderGroup.childForceExpandHeight = false;
inputHolderGroup.childControlHeight = true;
inputHolderGroup.SetChildControlHeight(true);
inputHolderGroup.childForceExpandWidth = false;
inputHolderGroup.childControlWidth = true;
inputHolderGroup.SetChildControlWidth(true);
var inputObj = UIFactory.CreateInputField(inputHolder);
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 bottomGroup = bottomRow.GetComponent<HorizontalLayoutGroup>();
bottomGroup.childForceExpandWidth = true;
bottomGroup.childControlWidth = true;
bottomGroup.SetChildControlWidth(true);
bottomGroup.spacing = 4;
var bottomLayout = bottomRow.AddComponent<LayoutElement>();
bottomLayout.minHeight = 25;

View File

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

View File

@ -21,7 +21,7 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var tabGroupObj = UIFactory.CreateHorizontalGroup(tabContent);
var tabGroup = tabGroupObj.GetComponent<HorizontalLayoutGroup>();
tabGroup.childForceExpandWidth = true;
tabGroup.childControlWidth = true;
tabGroup.SetChildControlWidth(true);
var tabLayout = tabGroupObj.AddComponent<LayoutElement>();
tabLayout.minWidth = 185;
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 rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childForceExpandWidth = true;
rowGroup.childControlWidth = true;
rowGroup.SetChildControlWidth(true);
rowGroup.spacing = 5;
rowGroup.padding.top = 2;
rowGroup.padding.bottom = 2;
@ -137,8 +137,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var viewerGroup = scrollContent.GetComponent<VerticalLayoutGroup>();
viewerGroup.childForceExpandHeight = false;
viewerGroup.childForceExpandWidth = false;
viewerGroup.childControlHeight = true;
viewerGroup.childControlWidth = true;
viewerGroup.SetChildControlHeight(true);
viewerGroup.SetChildControlWidth(true);
var mainLayout = textureViewerObj.GetComponent<LayoutElement>();
mainLayout.flexibleHeight = 9999;
mainLayout.flexibleWidth = 9999;
@ -275,8 +275,8 @@ namespace UnityExplorer.UI.Main.Home.Inspectors
var memFilterGroup = memberFilterRowObj.GetComponent<HorizontalLayoutGroup>();
memFilterGroup.childForceExpandHeight = false;
memFilterGroup.childForceExpandWidth = false;
memFilterGroup.childControlWidth = true;
memFilterGroup.childControlHeight = true;
memFilterGroup.SetChildControlWidth(true);
memFilterGroup.SetChildControlHeight(true);
memFilterGroup.spacing = 5;
var memFilterLayout = memberFilterRowObj.AddComponent<LayoutElement>();
memFilterLayout.minHeight = 25;

View File

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

View File

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

View File

@ -22,6 +22,8 @@ namespace UnityExplorer.UI.Main
public readonly List<BaseMenuPage> Pages = new List<BaseMenuPage>();
private BaseMenuPage m_activePage;
public static Action<int> OnActiveTabChanged;
// Navbar buttons
private Button m_lastNavButtonPressed;
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 int layoutInitIndex;
private int origDesiredPage = -1;
public void Update()
{
if (!pageLayoutInit)
{
if (origDesiredPage == -1)
origDesiredPage = ExplorerConfig.Instance?.Active_Tab ?? 0;
if (layoutInitIndex < Pages.Count)
{
SetPage(Pages[layoutInitIndex]);
@ -85,7 +92,7 @@ namespace UnityExplorer.UI.Main
{
pageLayoutInit = true;
MainPanel.transform.position = initPos;
SetPage(Pages[0]);
SetPage(Pages[origDesiredPage]);
}
return;
}
@ -98,19 +105,6 @@ namespace UnityExplorer.UI.Main
if (page == null || m_activePage == page)
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);
// unique case for console page, at the moment this will just go here
@ -128,6 +122,8 @@ namespace UnityExplorer.UI.Main
SetButtonInactiveColors(m_lastNavButtonPressed);
m_lastNavButtonPressed = button;
OnActiveTabChanged?.Invoke(Pages.IndexOf(m_activePage));
}
internal void SetButtonActiveColors(Button button)
@ -184,8 +180,8 @@ namespace UnityExplorer.UI.Main
GameObject titleBar = UIFactory.CreateHorizontalGroup(content);
HorizontalLayoutGroup titleGroup = titleBar.GetComponent<HorizontalLayoutGroup>();
titleGroup.childControlHeight = true;
titleGroup.childControlWidth = true;
titleGroup.SetChildControlHeight(true);
titleGroup.SetChildControlWidth(true);
titleGroup.childForceExpandHeight = true;
titleGroup.childForceExpandWidth = true;
titleGroup.padding.left = 15;
@ -248,8 +244,8 @@ namespace UnityExplorer.UI.Main
HorizontalLayoutGroup navGroup = navbarObj.GetComponent<HorizontalLayoutGroup>();
navGroup.spacing = 5;
navGroup.childControlHeight = true;
navGroup.childControlWidth = true;
navGroup.SetChildControlHeight(true);
navGroup.SetChildControlWidth(true);
navGroup.childForceExpandHeight = true;
navGroup.childForceExpandWidth = true;
@ -283,8 +279,8 @@ namespace UnityExplorer.UI.Main
{
GameObject mainObj = UIFactory.CreateHorizontalGroup(content);
HorizontalLayoutGroup mainGroup = mainObj.GetComponent<HorizontalLayoutGroup>();
mainGroup.childControlHeight = true;
mainGroup.childControlWidth = true;
mainGroup.SetChildControlHeight(true);
mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandHeight = true;
mainGroup.childForceExpandWidth = true;

View File

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

View File

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

View File

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

View File

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

View File

@ -97,8 +97,8 @@ namespace UnityExplorer.UI
img.color = Color.white;
VerticalLayoutGroup group = panelObj.AddComponent<VerticalLayoutGroup>();
group.childControlHeight = true;
group.childControlWidth = true;
group.SetChildControlHeight(true);
group.SetChildControlWidth(true);
group.childForceExpandHeight = true;
group.childForceExpandWidth = true;
@ -115,8 +115,8 @@ namespace UnityExplorer.UI
group2.padding.bottom = 3;
group2.padding.top = 3;
group2.spacing = 3;
group2.childControlHeight = true;
group2.childControlWidth = true;
group2.SetChildControlHeight(true);
group2.SetChildControlWidth(true);
group2.childForceExpandHeight = false;
group2.childForceExpandWidth = true;
@ -151,8 +151,8 @@ namespace UnityExplorer.UI
VerticalLayoutGroup horiGroup = groupObj.AddComponent<VerticalLayoutGroup>();
horiGroup.childAlignment = TextAnchor.UpperLeft;
horiGroup.childControlWidth = true;
horiGroup.childControlHeight = true;
horiGroup.SetChildControlWidth(true);
horiGroup.SetChildControlHeight(true);
Image image = groupObj.AddComponent<Image>();
if (color != default)
@ -173,8 +173,8 @@ namespace UnityExplorer.UI
HorizontalLayoutGroup horiGroup = groupObj.AddComponent<HorizontalLayoutGroup>();
horiGroup.childAlignment = TextAnchor.UpperLeft;
horiGroup.childControlWidth = true;
horiGroup.childControlHeight = true;
horiGroup.SetChildControlWidth(true);
horiGroup.SetChildControlHeight(true);
Image image = groupObj.AddComponent<Image>();
if (color != default)
@ -423,8 +423,8 @@ namespace UnityExplorer.UI
mainInput.colors = mainColors;
VerticalLayoutGroup mainGroup = mainObj.AddComponent<VerticalLayoutGroup>();
mainGroup.childControlHeight = true;
mainGroup.childControlWidth = true;
mainGroup.SetChildControlHeight(true);
mainGroup.SetChildControlWidth(true);
mainGroup.childForceExpandWidth = true;
mainGroup.childForceExpandHeight = true;
@ -655,9 +655,9 @@ namespace UnityExplorer.UI
var contentGroup = content.AddComponent<VerticalLayoutGroup>();
contentGroup.childForceExpandHeight = true;
contentGroup.childControlHeight = true;
contentGroup.SetChildControlHeight(true);
contentGroup.childForceExpandWidth = true;
contentGroup.childControlWidth = true;
contentGroup.SetChildControlWidth(true);
contentGroup.padding.left = 5;
contentGroup.padding.right = 5;
contentGroup.padding.top = 5;
@ -668,7 +668,7 @@ namespace UnityExplorer.UI
var scrollbarLayout = scrollBarObj.AddComponent<VerticalLayoutGroup>();
scrollbarLayout.childForceExpandHeight = true;
scrollbarLayout.childControlHeight = true;
scrollbarLayout.SetChildControlHeight(true);
RectTransform scrollBarRect = scrollBarObj.GetComponent<RectTransform>();
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 Sprite ResizeCursor { get; private set; }
//internal static Sprite ResizeCursor { get; private set; }
internal static Shader BackupShader { get; private set; }
public static bool ShowMenu
@ -76,6 +76,33 @@ namespace UnityExplorer.UI
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)
{
if (s_showMenu == show)
@ -96,12 +123,6 @@ namespace UnityExplorer.UI
CursorUnlocker.UpdateCursorControl();
}
//public static void OnSceneChange()
//{
// SceneExplorer.Instance?.OnSceneChange();
// SearchPage.Instance?.OnSceneChange();
//}
public static void Update()
{
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()
{
AssetBundle bundle = null;
@ -176,10 +179,12 @@ namespace UnityExplorer.UI
try
{
bundle = LoadExplorerUi("modern");
if (bundle == null)
throw new Exception();
}
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
{
@ -194,6 +199,7 @@ namespace UnityExplorer.UI
if (bundle == null)
{
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
return;
}
@ -206,38 +212,29 @@ namespace UnityExplorer.UI
Graphic.defaultGraphicMaterial.shader = BackupShader;
}
ResizeCursor = bundle.LoadAsset<Sprite>("cursor");
//ResizeCursor = bundle.LoadAsset<Sprite>("cursor");
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
ExplorerCore.Log("Loaded UI bundle");
}
private static GameObject CreateRootCanvas()
private static AssetBundle LoadExplorerUi(string id)
{
GameObject rootObj = new GameObject("ExplorerCanvas");
UnityEngine.Object.DontDestroyOnLoad(rootObj);
rootObj.layer = 5;
var data = ReadFully(typeof(ExplorerCore).Assembly.GetManifestResourceStream($"UnityExplorer.Resources.explorerui.{id}.bundle"));
return AssetBundle.LoadFromMemory(data);
}
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 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();
}
}
}
}