mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
1.5.3
* Added exception handling for scrollview when unstripping fails * Added some better logging in some places
This commit is contained in:
parent
51cfbe524e
commit
5de771389e
@ -12,7 +12,7 @@ namespace Explorer
|
|||||||
public class CppExplorer : MelonMod
|
public class CppExplorer : MelonMod
|
||||||
{
|
{
|
||||||
public const string GUID = "com.sinai.cppexplorer";
|
public const string GUID = "com.sinai.cppexplorer";
|
||||||
public const string VERSION = "1.5.2";
|
public const string VERSION = "1.5.3";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
|
|
||||||
public const string NAME = "CppExplorer"
|
public const string NAME = "CppExplorer"
|
||||||
@ -99,6 +99,8 @@ namespace Explorer
|
|||||||
|
|
||||||
public override void OnGUI()
|
public override void OnGUI()
|
||||||
{
|
{
|
||||||
|
if (!ShowMenu) return;
|
||||||
|
|
||||||
MainMenu.Instance.OnGUI();
|
MainMenu.Instance.OnGUI();
|
||||||
WindowManager.Instance.OnGUI();
|
WindowManager.Instance.OnGUI();
|
||||||
InspectUnderMouse.OnGUI();
|
InspectUnderMouse.OnGUI();
|
||||||
|
@ -10,6 +10,35 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public class UIHelpers
|
public class UIHelpers
|
||||||
{
|
{
|
||||||
|
private static bool ScrollUnstrippingFailed = false;
|
||||||
|
|
||||||
|
public static Vector2 BeginScrollView(Vector2 scroll) => BeginScrollView(scroll, null);
|
||||||
|
|
||||||
|
public static Vector2 BeginScrollView(Vector2 scroll, GUIStyle style, params GUILayoutOption[] layoutOptions)
|
||||||
|
{
|
||||||
|
if (ScrollUnstrippingFailed) return scroll;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (style != null)
|
||||||
|
return GUILayout.BeginScrollView(scroll, style, layoutOptions);
|
||||||
|
else
|
||||||
|
return GUILayout.BeginScrollView(scroll, layoutOptions);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
ScrollUnstrippingFailed = true;
|
||||||
|
return scroll;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EndScrollView()
|
||||||
|
{
|
||||||
|
if (ScrollUnstrippingFailed) return;
|
||||||
|
|
||||||
|
GUILayout.EndScrollView();
|
||||||
|
}
|
||||||
|
|
||||||
// helper for "Instantiate" button on UnityEngine.Objects
|
// helper for "Instantiate" button on UnityEngine.Objects
|
||||||
public static void InstantiateButton(Object obj, float width = 100)
|
public static void InstantiateButton(Object obj, float width = 100)
|
||||||
{
|
{
|
||||||
|
@ -51,15 +51,12 @@ namespace Explorer
|
|||||||
|
|
||||||
public void OnGUI()
|
public void OnGUI()
|
||||||
{
|
{
|
||||||
if (CppExplorer.ShowMenu)
|
var origSkin = GUI.skin;
|
||||||
{
|
GUI.skin = UIStyles.WindowSkin;
|
||||||
var origSkin = GUI.skin;
|
|
||||||
GUI.skin = UIStyles.WindowSkin;
|
|
||||||
|
|
||||||
MainRect = GUI.Window(MainWindowID, MainRect, (GUI.WindowFunction)MainWindow, CppExplorer.NAME);
|
MainRect = GUI.Window(MainWindowID, MainRect, (GUI.WindowFunction)MainWindow, CppExplorer.NAME);
|
||||||
|
|
||||||
GUI.skin = origSkin;
|
GUI.skin = origSkin;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindow(int id)
|
private void MainWindow(int id)
|
||||||
@ -77,9 +74,12 @@ namespace Explorer
|
|||||||
MainHeader();
|
MainHeader();
|
||||||
|
|
||||||
var page = Pages[m_currentPage];
|
var page = Pages[m_currentPage];
|
||||||
page.scroll = GUILayout.BeginScrollView(page.scroll, GUI.skin.scrollView);
|
|
||||||
|
page.scroll = UIHelpers.BeginScrollView(page.scroll);
|
||||||
|
|
||||||
page.DrawWindow();
|
page.DrawWindow();
|
||||||
GUILayout.EndScrollView();
|
|
||||||
|
UIHelpers.EndScrollView();
|
||||||
|
|
||||||
MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID);
|
MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID);
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ namespace Explorer
|
|||||||
|
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
resultsScroll = GUILayout.BeginScrollView(resultsScroll, GUI.skin.scrollView);
|
resultsScroll = UIHelpers.BeginScrollView(resultsScroll);
|
||||||
|
|
||||||
var _temprect = new Rect(MainMenu.MainRect.x, MainMenu.MainRect.y, MainMenu.MainRect.width + 160, MainMenu.MainRect.height);
|
var _temprect = new Rect(MainMenu.MainRect.x, MainMenu.MainRect.y, MainMenu.MainRect.width + 160, MainMenu.MainRect.height);
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ namespace Explorer
|
|||||||
GUILayout.Label("<color=red><i>No results found!</i></color>", null);
|
GUILayout.Label("<color=red><i>No results found!</i></color>", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.EndScrollView();
|
UIHelpers.EndScrollView();
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -73,8 +73,8 @@ namespace Explorer
|
|||||||
|
|
||||||
m_name = m_object.name;
|
m_name = m_object.name;
|
||||||
m_scene = string.IsNullOrEmpty(m_object.scene.name)
|
m_scene = string.IsNullOrEmpty(m_object.scene.name)
|
||||||
? "None"
|
? "None"
|
||||||
: m_object.scene.name;
|
: m_object.scene.name;
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ namespace Explorer
|
|||||||
|
|
||||||
private void DestroyOnException(Exception e)
|
private void DestroyOnException(Exception e)
|
||||||
{
|
{
|
||||||
MelonLogger.Log($"{e.GetType()}, {e.Message}");
|
MelonLogger.Log($"Exception drawing GameObject Window: {e.GetType()}, {e.Message}");
|
||||||
DestroyWindow();
|
DestroyWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ namespace Explorer
|
|||||||
GUILayout.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box);
|
GUILayout.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box);
|
||||||
}
|
}
|
||||||
|
|
||||||
scroll = GUILayout.BeginScrollView(scroll, GUI.skin.scrollView);
|
scroll = UIHelpers.BeginScrollView(scroll);
|
||||||
|
|
||||||
GUILayout.BeginHorizontal(null);
|
GUILayout.BeginHorizontal(null);
|
||||||
GUILayout.Label("Scene: <color=cyan>" + (m_scene == "" ? "n/a" : m_scene) + "</color>", null);
|
GUILayout.Label("Scene: <color=cyan>" + (m_scene == "" ? "n/a" : m_scene) + "</color>", null);
|
||||||
@ -220,7 +220,7 @@ namespace Explorer
|
|||||||
|
|
||||||
GameObjectControls();
|
GameObjectControls();
|
||||||
|
|
||||||
GUILayout.EndScrollView();
|
UIHelpers.EndScrollView();
|
||||||
|
|
||||||
if (!WindowManager.TabView)
|
if (!WindowManager.TabView)
|
||||||
{
|
{
|
||||||
@ -237,8 +237,8 @@ namespace Explorer
|
|||||||
|
|
||||||
private void TransformList(Rect m_rect)
|
private void TransformList(Rect m_rect)
|
||||||
{
|
{
|
||||||
GUILayout.BeginVertical(GUI.skin.box, null); // new GUILayoutOption[] { GUILayout.Height(250) });
|
GUILayout.BeginVertical(GUI.skin.box, null);
|
||||||
m_transformScroll = GUILayout.BeginScrollView(m_transformScroll, GUI.skin.scrollView);
|
m_transformScroll = UIHelpers.BeginScrollView(m_transformScroll);
|
||||||
|
|
||||||
GUILayout.Label("<b><size=15>Children</size></b>", null);
|
GUILayout.Label("<b><size=15>Children</size></b>", null);
|
||||||
|
|
||||||
@ -287,14 +287,14 @@ namespace Explorer
|
|||||||
GUILayout.Label("<i>None</i>", null);
|
GUILayout.Label("<i>None</i>", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.EndScrollView();
|
UIHelpers.EndScrollView();
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComponentList(Rect m_rect)
|
private void ComponentList(Rect m_rect)
|
||||||
{
|
{
|
||||||
GUILayout.BeginVertical(GUI.skin.box, null); // new GUILayoutOption[] { GUILayout.Height(250) });
|
GUILayout.BeginVertical(GUI.skin.box, null);
|
||||||
m_compScroll = GUILayout.BeginScrollView(m_compScroll, GUI.skin.scrollView);
|
m_compScroll = UIHelpers.BeginScrollView(m_compScroll);
|
||||||
GUILayout.Label("<b><size=15>Components</size></b>", null);
|
GUILayout.Label("<b><size=15>Components</size></b>", null);
|
||||||
|
|
||||||
GUILayout.BeginHorizontal(null);
|
GUILayout.BeginHorizontal(null);
|
||||||
@ -369,7 +369,7 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.EndScrollView();
|
UIHelpers.EndScrollView();
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ namespace Explorer
|
|||||||
|
|
||||||
// ====== BODY ======
|
// ====== BODY ======
|
||||||
|
|
||||||
scroll = GUILayout.BeginScrollView(scroll, GUI.skin.scrollView);
|
scroll = UIHelpers.BeginScrollView(scroll);
|
||||||
|
|
||||||
GUILayout.Space(10);
|
GUILayout.Space(10);
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
GUILayout.EndScrollView();
|
UIHelpers.EndScrollView();
|
||||||
|
|
||||||
if (!WindowManager.TabView)
|
if (!WindowManager.TabView)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user