mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-04 04:22:53 +08:00
3.0.4
see release notes
This commit is contained in:
@ -1,21 +1,22 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
using UnityExplorer.Config;
|
using UnityExplorer.Config;
|
||||||
using UnityExplorer.Input;
|
using UnityExplorer.Input;
|
||||||
|
using UnityExplorer.Inspectors;
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Modules;
|
using UnityExplorer.UI.Modules;
|
||||||
using UnityEngine;
|
#if CPP
|
||||||
using UnityExplorer.Inspectors;
|
|
||||||
using System.IO;
|
|
||||||
using UnityExplorer.Unstrip;
|
|
||||||
using UnityEngine.SceneManagement;
|
|
||||||
using UnityExplorer.Helpers;
|
using UnityExplorer.Helpers;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
public class ExplorerCore
|
public class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
public const string NAME = "UnityExplorer";
|
||||||
public const string VERSION = "3.0.3";
|
public const string VERSION = "3.0.4";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
public const string EXPLORER_FOLDER = @"Mods\UnityExplorer";
|
public const string EXPLORER_FOLDER = @"Mods\UnityExplorer";
|
||||||
|
@ -35,7 +35,6 @@ namespace UnityExplorer.Helpers
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
public static bool IsReadable(this Texture2D tex)
|
public static bool IsReadable(this Texture2D tex)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -68,6 +67,10 @@ namespace UnityExplorer.Helpers
|
|||||||
return _newTex;
|
return _newTex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CPP
|
||||||
|
internal delegate void d_Blit2(IntPtr source, IntPtr dest);
|
||||||
|
#endif
|
||||||
|
|
||||||
public static Texture2D ForceReadTexture(Texture2D tex)
|
public static Texture2D ForceReadTexture(Texture2D tex)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -78,7 +81,13 @@ namespace UnityExplorer.Helpers
|
|||||||
var rt = RenderTexture.GetTemporary(tex.width, tex.height, 0, RenderTextureFormat.ARGB32);
|
var rt = RenderTexture.GetTemporary(tex.width, tex.height, 0, RenderTextureFormat.ARGB32);
|
||||||
rt.filterMode = FilterMode.Point;
|
rt.filterMode = FilterMode.Point;
|
||||||
RenderTexture.active = rt;
|
RenderTexture.active = rt;
|
||||||
|
|
||||||
|
#if MONO
|
||||||
Graphics.Blit(tex, rt);
|
Graphics.Blit(tex, rt);
|
||||||
|
#else
|
||||||
|
var iCall = ICallHelper.GetICall<d_Blit2>("UnityEngine.Graphics::Blit2");
|
||||||
|
iCall.Invoke(tex.Pointer, rt.Pointer);
|
||||||
|
#endif
|
||||||
|
|
||||||
var _newTex = new Texture2D(tex.width, tex.height, TextureFormat.ARGB32, false);
|
var _newTex = new Texture2D(tex.width, tex.height, TextureFormat.ARGB32, false);
|
||||||
|
|
||||||
|
@ -231,23 +231,34 @@ namespace UnityExplorer.Inspectors
|
|||||||
invisGroup.spacing = 10;
|
invisGroup.spacing = 10;
|
||||||
|
|
||||||
// inspect under mouse button
|
// inspect under mouse button
|
||||||
|
AddMouseInspectButton(topRowObj, MouseInspector.MouseInspectMode.UI);
|
||||||
|
AddMouseInspectButton(topRowObj, MouseInspector.MouseInspectMode.World);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AddMouseInspectButton(GameObject topRowObj, MouseInspector.MouseInspectMode mode)
|
||||||
|
{
|
||||||
var inspectObj = UIFactory.CreateButton(topRowObj);
|
var inspectObj = UIFactory.CreateButton(topRowObj);
|
||||||
var inspectLayout = inspectObj.AddComponent<LayoutElement>();
|
var inspectLayout = inspectObj.AddComponent<LayoutElement>();
|
||||||
inspectLayout.minWidth = 120;
|
inspectLayout.minWidth = 120;
|
||||||
inspectLayout.flexibleWidth = 0;
|
inspectLayout.flexibleWidth = 0;
|
||||||
|
|
||||||
|
var inspectText = inspectObj.GetComponentInChildren<Text>();
|
||||||
|
inspectText.text = "Mouse Inspect";
|
||||||
|
inspectText.fontSize = 13;
|
||||||
|
|
||||||
|
if (mode == MouseInspector.MouseInspectMode.UI)
|
||||||
|
inspectText.text += " (UI)";
|
||||||
|
|
||||||
var inspectBtn = inspectObj.GetComponent<Button>();
|
var inspectBtn = inspectObj.GetComponent<Button>();
|
||||||
var inspectColors = inspectBtn.colors;
|
var inspectColors = inspectBtn.colors;
|
||||||
inspectColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
|
inspectColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
|
||||||
inspectBtn.colors = inspectColors;
|
inspectBtn.colors = inspectColors;
|
||||||
var inspectText = inspectObj.GetComponentInChildren<Text>();
|
|
||||||
inspectText.text = "Mouse Inspect";
|
|
||||||
inspectText.fontSize = 13;
|
|
||||||
|
|
||||||
inspectBtn.onClick.AddListener(OnInspectMouseClicked);
|
inspectBtn.onClick.AddListener(OnInspectMouseClicked);
|
||||||
|
|
||||||
void OnInspectMouseClicked()
|
void OnInspectMouseClicked()
|
||||||
{
|
{
|
||||||
|
MouseInspector.Mode = mode;
|
||||||
MouseInspector.StartInspect();
|
MouseInspector.StartInspect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,27 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Helpers;
|
using UnityExplorer.Helpers;
|
||||||
using UnityExplorer.Input;
|
using UnityExplorer.Input;
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
|
using UnityExplorer.Unstrip;
|
||||||
|
|
||||||
namespace UnityExplorer.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public class MouseInspector
|
public class MouseInspector
|
||||||
{
|
{
|
||||||
|
public enum MouseInspectMode
|
||||||
|
{
|
||||||
|
World,
|
||||||
|
UI
|
||||||
|
}
|
||||||
|
|
||||||
public static bool Enabled { get; set; }
|
public static bool Enabled { get; set; }
|
||||||
|
|
||||||
//internal static Text s_objUnderMouseName;
|
public static MouseInspectMode Mode { get; set; }
|
||||||
|
|
||||||
internal static Text s_objNameLabel;
|
internal static Text s_objNameLabel;
|
||||||
internal static Text s_objPathLabel;
|
internal static Text s_objPathLabel;
|
||||||
internal static Text s_mousePosLabel;
|
internal static Text s_mousePosLabel;
|
||||||
@ -29,6 +38,18 @@ namespace UnityExplorer.Inspectors
|
|||||||
Enabled = true;
|
Enabled = true;
|
||||||
MainMenu.Instance.MainPanel.SetActive(false);
|
MainMenu.Instance.MainPanel.SetActive(false);
|
||||||
s_UIContent.SetActive(true);
|
s_UIContent.SetActive(true);
|
||||||
|
|
||||||
|
// recache Graphic Raycasters each time we start
|
||||||
|
var casters = ResourcesUnstrip.FindObjectsOfTypeAll(typeof(GraphicRaycaster));
|
||||||
|
m_gCasters = new GraphicRaycaster[casters.Length];
|
||||||
|
for (int i = 0; i < casters.Length; i++)
|
||||||
|
{
|
||||||
|
#if CPP
|
||||||
|
m_gCasters[i] = casters[i].TryCast<GraphicRaycaster>();
|
||||||
|
#else
|
||||||
|
m_gCasters[i] = casters[i] as GraphicRaycaster;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StopInspect()
|
public static void StopInspect()
|
||||||
@ -40,49 +61,68 @@ namespace UnityExplorer.Inspectors
|
|||||||
ClearHitData();
|
ClearHitData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static GraphicRaycaster[] m_gCasters;
|
||||||
|
|
||||||
public static void UpdateInspect()
|
public static void UpdateInspect()
|
||||||
{
|
{
|
||||||
if (InputManager.GetKeyDown(KeyCode.Escape))
|
if (InputManager.GetKeyDown(KeyCode.Escape))
|
||||||
{
|
{
|
||||||
StopInspect();
|
StopInspect();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mousePos = InputManager.MousePosition;
|
var mousePos = InputManager.MousePosition;
|
||||||
|
|
||||||
if (mousePos != s_lastMousePos)
|
if (mousePos != s_lastMousePos)
|
||||||
{
|
UpdatePosition(mousePos);
|
||||||
s_lastMousePos = mousePos;
|
|
||||||
|
|
||||||
var inversePos = UIManager.CanvasRoot.transform.InverseTransformPoint(mousePos);
|
|
||||||
|
|
||||||
s_mousePosLabel.text = $"<color=grey>Mouse Position:</color> {((Vector2)InputManager.MousePosition).ToString()}";
|
|
||||||
|
|
||||||
float yFix = mousePos.y < 120 ? 80 : -80;
|
|
||||||
|
|
||||||
s_UIContent.transform.localPosition = new Vector3(inversePos.x, inversePos.y + yFix, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!UnityHelpers.MainCamera)
|
if (!UnityHelpers.MainCamera)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// actual inspect raycast
|
// actual inspect raycast
|
||||||
var ray = UnityHelpers.MainCamera.ScreenPointToRay(mousePos);
|
|
||||||
|
|
||||||
if (Physics.Raycast(ray, out RaycastHit hit, 1000f))
|
switch (Mode)
|
||||||
{
|
{
|
||||||
var obj = hit.transform.gameObject;
|
case MouseInspectMode.UI:
|
||||||
|
RaycastUI(mousePos); break;
|
||||||
|
case MouseInspectMode.World:
|
||||||
|
RaycastWorld(mousePos); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (obj != s_lastHit)
|
internal static void OnHitGameObject(GameObject obj)
|
||||||
{
|
{
|
||||||
s_lastHit = obj;
|
if (obj != s_lastHit)
|
||||||
s_objNameLabel.text = $"<b>Click to Inspect:</b> <color=cyan>{obj.name}</color>";
|
{
|
||||||
s_objPathLabel.text = $"Path: {obj.transform.GetTransformPath(true)}";
|
s_lastHit = obj;
|
||||||
}
|
s_objNameLabel.text = $"<b>Click to Inspect:</b> <color=cyan>{obj.name}</color>";
|
||||||
|
s_objPathLabel.text = $"Path: {obj.transform.GetTransformPath(true)}";
|
||||||
|
}
|
||||||
|
|
||||||
if (InputManager.GetMouseButtonDown(0))
|
if (InputManager.GetMouseButtonDown(0))
|
||||||
|
{
|
||||||
|
StopInspect();
|
||||||
|
InspectorManager.Instance.Inspect(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void RaycastWorld(Vector2 mousePos)
|
||||||
|
{
|
||||||
|
var ray = UnityHelpers.MainCamera.ScreenPointToRay(mousePos);
|
||||||
|
var casts = Physics.RaycastAll(ray, 1000f);
|
||||||
|
|
||||||
|
if (casts.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (var cast in casts)
|
||||||
{
|
{
|
||||||
StopInspect();
|
if (cast.transform)
|
||||||
InspectorManager.Instance.Inspect(obj);
|
{
|
||||||
|
var obj = cast.transform.gameObject;
|
||||||
|
|
||||||
|
OnHitGameObject(obj);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -92,6 +132,56 @@ namespace UnityExplorer.Inspectors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void RaycastUI(Vector2 mousePos)
|
||||||
|
{
|
||||||
|
var ped = new PointerEventData(null)
|
||||||
|
{
|
||||||
|
position = mousePos
|
||||||
|
};
|
||||||
|
|
||||||
|
#if MONO
|
||||||
|
var list = new List<RaycastResult>();
|
||||||
|
#else
|
||||||
|
var list = new Il2CppSystem.Collections.Generic.List<RaycastResult>();
|
||||||
|
#endif
|
||||||
|
foreach (var gr in m_gCasters)
|
||||||
|
{
|
||||||
|
gr.Raycast(ped, list);
|
||||||
|
|
||||||
|
if (list.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var hit in list)
|
||||||
|
{
|
||||||
|
if (hit.gameObject)
|
||||||
|
{
|
||||||
|
var obj = hit.gameObject;
|
||||||
|
|
||||||
|
OnHitGameObject(obj);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (s_lastHit)
|
||||||
|
ClearHitData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void UpdatePosition(Vector2 mousePos)
|
||||||
|
{
|
||||||
|
s_lastMousePos = mousePos;
|
||||||
|
|
||||||
|
var inversePos = UIManager.CanvasRoot.transform.InverseTransformPoint(mousePos);
|
||||||
|
|
||||||
|
s_mousePosLabel.text = $"<color=grey>Mouse Position:</color> {mousePos.ToString()}";
|
||||||
|
|
||||||
|
float yFix = mousePos.y < 120 ? 80 : -80;
|
||||||
|
s_UIContent.transform.localPosition = new Vector3(inversePos.x, inversePos.y + yFix, 0);
|
||||||
|
}
|
||||||
|
|
||||||
internal static void ClearHitData()
|
internal static void ClearHitData()
|
||||||
{
|
{
|
||||||
s_lastHit = null;
|
s_lastHit = null;
|
||||||
@ -99,7 +189,7 @@ namespace UnityExplorer.Inspectors
|
|||||||
s_objPathLabel.text = "";
|
s_objPathLabel.text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#region UI Construction
|
#region UI Construction
|
||||||
|
|
||||||
internal static void ConstructUI()
|
internal static void ConstructUI()
|
||||||
{
|
{
|
||||||
@ -112,7 +202,10 @@ namespace UnityExplorer.Inspectors
|
|||||||
baseRect.anchorMin = half;
|
baseRect.anchorMin = half;
|
||||||
baseRect.anchorMax = half;
|
baseRect.anchorMax = half;
|
||||||
baseRect.pivot = half;
|
baseRect.pivot = half;
|
||||||
baseRect.sizeDelta = new Vector2(700, 100);
|
baseRect.sizeDelta = new Vector2(700, 150);
|
||||||
|
|
||||||
|
var group = content.GetComponent<VerticalLayoutGroup>();
|
||||||
|
group.childForceExpandHeight = true;
|
||||||
|
|
||||||
// Title text
|
// Title text
|
||||||
|
|
||||||
@ -131,13 +224,16 @@ namespace UnityExplorer.Inspectors
|
|||||||
|
|
||||||
var pathLabelObj = UIFactory.CreateLabel(content, TextAnchor.MiddleLeft);
|
var pathLabelObj = UIFactory.CreateLabel(content, TextAnchor.MiddleLeft);
|
||||||
s_objPathLabel = pathLabelObj.GetComponent<Text>();
|
s_objPathLabel = pathLabelObj.GetComponent<Text>();
|
||||||
s_objPathLabel.color = Color.grey;
|
|
||||||
s_objPathLabel.fontStyle = FontStyle.Italic;
|
s_objPathLabel.fontStyle = FontStyle.Italic;
|
||||||
s_objPathLabel.horizontalOverflow = HorizontalWrapMode.Overflow;
|
s_objPathLabel.horizontalOverflow = HorizontalWrapMode.Wrap;
|
||||||
|
|
||||||
|
var pathLayout = pathLabelObj.AddComponent<LayoutElement>();
|
||||||
|
pathLayout.minHeight = 75;
|
||||||
|
pathLayout.flexibleHeight = 0;
|
||||||
|
|
||||||
s_UIContent.SetActive(false);
|
s_UIContent.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,7 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
|
|
||||||
if (m_subContentConstructed)
|
if (m_subContentConstructed)
|
||||||
{
|
{
|
||||||
// changing types, destroy subcontent
|
DestroySubContent();
|
||||||
for (int i = 0; i < m_subContentParent.transform.childCount; i++)
|
|
||||||
{
|
|
||||||
var child = m_subContentParent.transform.GetChild(i);
|
|
||||||
GameObject.Destroy(child.gameObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_subContentConstructed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s_enumNamesCache.ContainsKey(type))
|
if (!s_enumNamesCache.ContainsKey(type))
|
||||||
|
@ -14,8 +14,9 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
{
|
{
|
||||||
public InteractiveString(object value, Type valueType) : base(value, valueType) { }
|
public InteractiveString(object value, Type valueType) : base(value, valueType) { }
|
||||||
|
|
||||||
public override bool HasSubContent => false;
|
public override bool HasSubContent => true;
|
||||||
public override bool SubContentWanted => false;
|
public override bool SubContentWanted => true;
|
||||||
|
|
||||||
public override bool WantInspectBtn => false;
|
public override bool WantInspectBtn => false;
|
||||||
|
|
||||||
public override void OnValueUpdated()
|
public override void OnValueUpdated()
|
||||||
@ -27,10 +28,9 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
{
|
{
|
||||||
base.OnException(member);
|
base.OnException(member);
|
||||||
|
|
||||||
if (m_hiddenObj.gameObject.activeSelf)
|
if (m_subContentConstructed && m_hiddenObj.gameObject.activeSelf)
|
||||||
m_hiddenObj.gameObject.SetActive(false);
|
m_hiddenObj.gameObject.SetActive(false);
|
||||||
|
|
||||||
// m_baseLabel.text = DefaultLabel;
|
|
||||||
m_labelLayout.minWidth = 200;
|
m_labelLayout.minWidth = 200;
|
||||||
m_labelLayout.flexibleWidth = 5000;
|
m_labelLayout.flexibleWidth = 5000;
|
||||||
}
|
}
|
||||||
@ -45,39 +45,62 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_hiddenObj.gameObject.activeSelf)
|
|
||||||
m_hiddenObj.gameObject.SetActive(true);
|
|
||||||
|
|
||||||
m_baseLabel.text = m_richValueType;
|
m_baseLabel.text = m_richValueType;
|
||||||
|
|
||||||
if (Value != null)
|
if (m_subContentConstructed)
|
||||||
{
|
{
|
||||||
var toString = Value.ToString();
|
if (!m_hiddenObj.gameObject.activeSelf)
|
||||||
|
m_hiddenObj.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty((string)Value))
|
||||||
|
{
|
||||||
|
var toString = (string)Value;
|
||||||
if (toString.Length > 15000)
|
if (toString.Length > 15000)
|
||||||
toString = toString.Substring(0, 15000);
|
toString = toString.Substring(0, 15000);
|
||||||
|
|
||||||
m_valueInput.text = toString;
|
m_readonlyInput.text = toString;
|
||||||
m_placeholderText.text = toString;
|
|
||||||
|
if (m_subContentConstructed)
|
||||||
|
{
|
||||||
|
m_valueInput.text = toString;
|
||||||
|
m_placeholderText.text = toString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_valueInput.text = "";
|
string s = Value == null
|
||||||
m_placeholderText.text = "null";
|
? "null"
|
||||||
|
: "empty";
|
||||||
|
|
||||||
|
m_readonlyInput.text = $"<i><color=grey>{s}</color></i>";
|
||||||
|
|
||||||
|
if (m_subContentConstructed)
|
||||||
|
{
|
||||||
|
m_valueInput.text = "";
|
||||||
|
m_placeholderText.text = s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_labelLayout.minWidth = 50;
|
m_labelLayout.minWidth = 50;
|
||||||
m_labelLayout.flexibleWidth = 0;
|
m_labelLayout.flexibleWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal void OnApplyClicked()
|
internal void OnApplyClicked()
|
||||||
{
|
{
|
||||||
Value = m_valueInput.text;
|
Value = m_valueInput.text;
|
||||||
Owner.SetValue();
|
Owner.SetValue();
|
||||||
|
RefreshUIForValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal InputField m_valueInput;
|
// for the default label
|
||||||
internal LayoutElement m_labelLayout;
|
internal LayoutElement m_labelLayout;
|
||||||
|
|
||||||
|
//internal InputField m_readonlyInput;
|
||||||
|
internal Text m_readonlyInput;
|
||||||
|
|
||||||
|
// for input
|
||||||
|
internal InputField m_valueInput;
|
||||||
internal GameObject m_hiddenObj;
|
internal GameObject m_hiddenObj;
|
||||||
internal Text m_placeholderText;
|
internal Text m_placeholderText;
|
||||||
|
|
||||||
@ -90,12 +113,38 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
|
|
||||||
m_labelLayout = m_baseLabel.gameObject.GetComponent<LayoutElement>();
|
m_labelLayout = m_baseLabel.gameObject.GetComponent<LayoutElement>();
|
||||||
|
|
||||||
m_hiddenObj = UIFactory.CreateLabel(m_valueContent, TextAnchor.MiddleLeft);
|
var readonlyInputObj = UIFactory.CreateLabel(m_valueContent, TextAnchor.MiddleLeft);
|
||||||
|
m_readonlyInput = readonlyInputObj.GetComponent<Text>();
|
||||||
|
m_readonlyInput.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||||
|
|
||||||
|
var testFitter = readonlyInputObj.AddComponent<ContentSizeFitter>();
|
||||||
|
testFitter.verticalFit = ContentSizeFitter.FitMode.MinSize;
|
||||||
|
|
||||||
|
var labelLayout = readonlyInputObj.AddComponent<LayoutElement>();
|
||||||
|
labelLayout.minHeight = 25;
|
||||||
|
labelLayout.preferredHeight = 25;
|
||||||
|
labelLayout.flexibleHeight = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ConstructSubcontent()
|
||||||
|
{
|
||||||
|
base.ConstructSubcontent();
|
||||||
|
|
||||||
|
var groupObj = UIFactory.CreateVerticalGroup(m_subContentParent, new Color(1, 1, 1, 0));
|
||||||
|
var group = groupObj.GetComponent<VerticalLayoutGroup>();
|
||||||
|
group.spacing = 4;
|
||||||
|
group.padding.top = 3;
|
||||||
|
group.padding.left = 3;
|
||||||
|
group.padding.right = 3;
|
||||||
|
group.padding.bottom = 3;
|
||||||
|
|
||||||
|
m_hiddenObj = UIFactory.CreateLabel(groupObj, TextAnchor.MiddleLeft);
|
||||||
m_hiddenObj.SetActive(false);
|
m_hiddenObj.SetActive(false);
|
||||||
var hiddenText = m_hiddenObj.GetComponent<Text>();
|
var hiddenText = m_hiddenObj.GetComponent<Text>();
|
||||||
hiddenText.color = Color.clear;
|
hiddenText.color = Color.clear;
|
||||||
hiddenText.fontSize = 14;
|
hiddenText.fontSize = 14;
|
||||||
hiddenText.raycastTarget = false;
|
hiddenText.raycastTarget = false;
|
||||||
|
hiddenText.supportRichText = false;
|
||||||
var hiddenFitter = m_hiddenObj.AddComponent<ContentSizeFitter>();
|
var hiddenFitter = m_hiddenObj.AddComponent<ContentSizeFitter>();
|
||||||
hiddenFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
hiddenFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||||
var hiddenLayout = m_hiddenObj.AddComponent<LayoutElement>();
|
var hiddenLayout = m_hiddenObj.AddComponent<LayoutElement>();
|
||||||
@ -121,19 +170,23 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
|
|
||||||
m_placeholderText = m_valueInput.placeholder.GetComponent<Text>();
|
m_placeholderText = m_valueInput.placeholder.GetComponent<Text>();
|
||||||
|
|
||||||
m_valueInput.onValueChanged.AddListener((string val) =>
|
m_placeholderText.supportRichText = false;
|
||||||
|
m_valueInput.textComponent.supportRichText = false;
|
||||||
|
|
||||||
|
m_valueInput.onValueChanged.AddListener((string val) =>
|
||||||
{
|
{
|
||||||
hiddenText.text = val;
|
hiddenText.text = val ?? "";
|
||||||
LayoutRebuilder.ForceRebuildLayoutImmediate(Owner.m_mainRect);
|
LayoutRebuilder.ForceRebuildLayoutImmediate(Owner.m_mainRect);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Owner.CanWrite)
|
if (Owner.CanWrite)
|
||||||
{
|
{
|
||||||
var applyBtnObj = UIFactory.CreateButton(m_valueContent, new Color(0.2f, 0.2f, 0.2f));
|
var applyBtnObj = UIFactory.CreateButton(groupObj, new Color(0.2f, 0.2f, 0.2f));
|
||||||
var applyLayout = applyBtnObj.AddComponent<LayoutElement>();
|
var applyLayout = applyBtnObj.AddComponent<LayoutElement>();
|
||||||
applyLayout.minWidth = 50;
|
applyLayout.minWidth = 50;
|
||||||
applyLayout.minHeight = 25;
|
applyLayout.minHeight = 25;
|
||||||
applyLayout.flexibleWidth = 0;
|
applyLayout.flexibleWidth = 0;
|
||||||
|
|
||||||
var applyBtn = applyBtnObj.GetComponent<Button>();
|
var applyBtn = applyBtnObj.GetComponent<Button>();
|
||||||
applyBtn.onClick.AddListener(OnApplyClicked);
|
applyBtn.onClick.AddListener(OnApplyClicked);
|
||||||
|
|
||||||
@ -144,6 +197,8 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
{
|
{
|
||||||
m_valueInput.readOnly = true;
|
m_valueInput.readOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefreshUIForValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,14 +226,15 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
|
|
||||||
if (StructInfo != null)
|
if (StructInfo != null)
|
||||||
{
|
{
|
||||||
// changing types, destroy subcontent
|
DestroySubContent();
|
||||||
for (int i = 0; i < m_subContentParent.transform.childCount; i++)
|
//// changing types, destroy subcontent
|
||||||
{
|
//for (int i = 0; i < m_subContentParent.transform.childCount; i++)
|
||||||
var child = m_subContentParent.transform.GetChild(i);
|
//{
|
||||||
GameObject.Destroy(child.gameObject);
|
// var child = m_subContentParent.transform.GetChild(i);
|
||||||
}
|
// GameObject.Destroy(child.gameObject);
|
||||||
|
//}
|
||||||
|
|
||||||
m_UIConstructed = false;
|
//m_UIConstructed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lastStructType = type;
|
m_lastStructType = type;
|
||||||
|
@ -78,7 +78,13 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
m_valueContent.SetActive(false);
|
m_valueContent.SetActive(false);
|
||||||
GameObject.Destroy(this.m_valueContent.gameObject);
|
GameObject.Destroy(this.m_valueContent.gameObject);
|
||||||
}
|
}
|
||||||
if (this.m_subContentParent && SubContentWanted)
|
|
||||||
|
DestroySubContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void DestroySubContent()
|
||||||
|
{
|
||||||
|
if (this.m_subContentParent && HasSubContent)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this.m_subContentParent.transform.childCount; i++)
|
for (int i = 0; i < this.m_subContentParent.transform.childCount; i++)
|
||||||
{
|
{
|
||||||
@ -87,6 +93,8 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
GameObject.Destroy(child.gameObject);
|
GameObject.Destroy(child.gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_subContentConstructed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnValueUpdated()
|
public virtual void OnValueUpdated()
|
||||||
@ -95,18 +103,16 @@ namespace UnityExplorer.Inspectors.Reflection
|
|||||||
ConstructUI(m_mainContentParent, m_subContentParent);
|
ConstructUI(m_mainContentParent, m_subContentParent);
|
||||||
|
|
||||||
if (Owner is CacheMember ownerMember && !string.IsNullOrEmpty(ownerMember.ReflectionException))
|
if (Owner is CacheMember ownerMember && !string.IsNullOrEmpty(ownerMember.ReflectionException))
|
||||||
{
|
|
||||||
OnException(ownerMember);
|
OnException(ownerMember);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
RefreshUIForValue();
|
RefreshUIForValue();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnException(CacheMember member)
|
public virtual void OnException(CacheMember member)
|
||||||
{
|
{
|
||||||
m_baseLabel.text = "<color=red>" + member.ReflectionException + "</color>";
|
if (m_UIConstructed)
|
||||||
|
m_baseLabel.text = "<color=red>" + member.ReflectionException + "</color>";
|
||||||
|
|
||||||
Value = null;
|
Value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,12 @@ namespace UnityExplorer.Tests
|
|||||||
|
|
||||||
public class TestClass
|
public class TestClass
|
||||||
{
|
{
|
||||||
|
public string AAALongString = @"1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5";
|
||||||
|
|
||||||
public Vector2 AATestVector2 = new Vector2(1, 2);
|
public Vector2 AATestVector2 = new Vector2(1, 2);
|
||||||
public Vector3 AATestVector3 = new Vector3(1, 2, 3);
|
public Vector3 AATestVector3 = new Vector3(1, 2, 3);
|
||||||
public Vector4 AATestVector4 = new Vector4(1, 2, 3, 4);
|
public Vector4 AATestVector4 = new Vector4(1, 2, 3, 4);
|
||||||
|
@ -260,11 +260,8 @@ namespace UnityExplorer.UI.Modules
|
|||||||
|
|
||||||
if (searchType == null)
|
if (searchType == null)
|
||||||
return;
|
return;
|
||||||
#if MONO
|
|
||||||
var allObjects = ResourcesUnstrip.FindObjectsOfTypeAll(searchType);
|
var allObjects = ResourcesUnstrip.FindObjectsOfTypeAll(searchType);
|
||||||
#else
|
|
||||||
var allObjects = ResourcesUnstrip.FindObjectsOfTypeAll(Il2CppType.From(searchType));
|
|
||||||
#endif
|
|
||||||
var results = new List<object>();
|
var results = new List<object>();
|
||||||
|
|
||||||
// perform filter comparers
|
// perform filter comparers
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<RootNamespace>UnityExplorer</RootNamespace>
|
<RootNamespace>UnityExplorer</RootNamespace>
|
||||||
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->
|
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->
|
||||||
<BIECppGameFolder>D:\Steam\steamapps\common\Outward</BIECppGameFolder>
|
<BIECppGameFolder>D:\source\Unity Projects\Test\_BUILD</BIECppGameFolder>
|
||||||
<!-- Set this to the BepInEx Mono Game folder, without the ending '\' character. -->
|
<!-- Set this to the BepInEx Mono Game folder, without the ending '\' character. -->
|
||||||
<BIEMonoGameFolder>D:\source\Unity Projects\Test\_BUILD_MONO</BIEMonoGameFolder>
|
<BIEMonoGameFolder>D:\source\Unity Projects\Test\_BUILD_MONO</BIEMonoGameFolder>
|
||||||
<!-- Set this to the BepInEx Mono Managed folder, without the ending '\' character. -->
|
<!-- Set this to the BepInEx Mono Managed folder, without the ending '\' character. -->
|
||||||
<BIEMonoManagedFolder>D:\source\Unity Projects\Test\_BUILD_MONO\Test_Data\Managed</BIEMonoManagedFolder>
|
<BIEMonoManagedFolder>D:\source\Unity Projects\Test\_BUILD_MONO\Test_Data\Managed</BIEMonoManagedFolder>
|
||||||
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
|
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
|
||||||
<MLCppGameFolder>D:\Steam\steamapps\common\VRChat</MLCppGameFolder>
|
<MLCppGameFolder>D:\source\Unity Projects\Test\_BUILD</MLCppGameFolder>
|
||||||
<!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. -->
|
<!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. -->
|
||||||
<MLMonoGameFolder>D:\source\Unity Projects\Test\_BUILD_MONO</MLMonoGameFolder>
|
<MLMonoGameFolder>D:\source\Unity Projects\Test\_BUILD_MONO</MLMonoGameFolder>
|
||||||
<!-- Set this to the MelonLoader Mono Managed folder, without the ending '\' character. -->
|
<!-- Set this to the MelonLoader Mono Managed folder, without the ending '\' character. -->
|
||||||
|
@ -3,24 +3,27 @@ using Mono.CSharp;
|
|||||||
using UnityExplorer.Helpers;
|
using UnityExplorer.Helpers;
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnhollowerBaseLib;
|
using UnhollowerBaseLib;
|
||||||
|
using UnhollowerRuntimeLib;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace UnityExplorer.Unstrip
|
namespace UnityExplorer.Unstrip
|
||||||
{
|
{
|
||||||
public class ResourcesUnstrip
|
public class ResourcesUnstrip
|
||||||
{
|
{
|
||||||
|
public static UnityEngine.Object[] FindObjectsOfTypeAll(Type type)
|
||||||
|
{
|
||||||
|
#if MONO
|
||||||
|
return UnityEngine.Resources.FindObjectsOfTypeAll(type);
|
||||||
|
#else
|
||||||
|
var iCall = ICallHelper.GetICall<d_FindObjectsOfTypeAll>("UnityEngine.Resources::FindObjectsOfTypeAll");
|
||||||
|
var cppType = Il2CppType.From(type);
|
||||||
|
|
||||||
|
return new Il2CppReferenceArray<UnityEngine.Object>(iCall.Invoke(cppType.Pointer));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if CPP
|
#if CPP
|
||||||
internal delegate IntPtr d_FindObjectsOfTypeAll(IntPtr type);
|
internal delegate IntPtr d_FindObjectsOfTypeAll(IntPtr type);
|
||||||
|
|
||||||
public static UnityEngine.Object[] FindObjectsOfTypeAll(Il2CppSystem.Type type)
|
|
||||||
{
|
|
||||||
var iCall = ICallHelper.GetICall<d_FindObjectsOfTypeAll>("UnityEngine.Resources::FindObjectsOfTypeAll");
|
|
||||||
|
|
||||||
return new Il2CppReferenceArray<UnityEngine.Object>(iCall.Invoke(type.Pointer));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
public static UnityEngine.Object[] FindObjectsOfTypeAll(Type type) => UnityEngine.Resources.FindObjectsOfTypeAll(type);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user