diff --git a/src/Input/InputManager.cs b/src/Input/InputManager.cs
index 81015a4..127d495 100644
--- a/src/Input/InputManager.cs
+++ b/src/Input/InputManager.cs
@@ -8,7 +8,6 @@ using UnhollowerBaseLib;
namespace UnityExplorer.Input
{
- [SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Unity style")]
public static class InputManager
{
private static IHandleInput m_inputModule;
diff --git a/src/Inspectors/GameObjectInspector.cs b/src/Inspectors/GameObjectInspector.cs
index 787b1a0..b27fedf 100644
--- a/src/Inspectors/GameObjectInspector.cs
+++ b/src/Inspectors/GameObjectInspector.cs
@@ -7,13 +7,13 @@ using UnityExplorer.Unstrip;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
-using UnityExplorer.Inspectors.GOInspector;
+using UnityExplorer.Inspectors.GameObjects;
namespace UnityExplorer.Inspectors
{
public class GameObjectInspector : InspectorBase
{
- public override string TabLabel => $" [G] {TargetGO?.name}";
+ public override string TabLabel => $" [G] {TargetGO?.name}";
public static GameObjectInspector ActiveInstance { get; private set; }
@@ -35,12 +35,15 @@ namespace UnityExplorer.Inspectors
set => s_content = value;
}
- public static TMP_InputField m_nameInput;
private static string m_lastName;
- public static TMP_InputField m_pathInput;
+ public static TMP_InputField m_nameInput;
+
private static string m_lastPath;
+ public static TMP_InputField m_pathInput;
+ private static RectTransform m_pathInputRect;
private static GameObject m_pathGroupObj;
private static Text m_hiddenPathText;
+ private static RectTransform m_hiddenPathRect;
private static Toggle m_enabledToggle;
private static Text m_enabledText;
@@ -77,15 +80,15 @@ namespace UnityExplorer.Inspectors
}
}
- public override void SetContentActive()
+ public override void SetActive()
{
- base.SetContentActive();
+ base.SetActive();
ActiveInstance = this;
}
- public override void SetContentInactive()
+ public override void SetInactive()
{
- base.SetContentInactive();
+ base.SetInactive();
ActiveInstance = null;
}
@@ -103,7 +106,7 @@ namespace UnityExplorer.Inspectors
{
base.Update();
- if (m_pendingDestroy || ActiveInstance != this)
+ if (m_pendingDestroy || !this.IsActive)
return;
RefreshTopInfo();
@@ -135,9 +138,12 @@ namespace UnityExplorer.Inspectors
if (m_lastPath != path)
{
m_lastPath = path;
+
m_pathInput.text = path;
m_hiddenPathText.text = path;
- m_pathInput.ForceLabelUpdate();
+
+ LayoutRebuilder.ForceRebuildLayoutImmediate(m_pathInputRect);
+ LayoutRebuilder.ForceRebuildLayoutImmediate(m_hiddenPathRect);
}
}
else if (m_pathGroupObj.activeSelf)
@@ -271,8 +277,8 @@ namespace UnityExplorer.Inspectors
hiddenFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
var hiddenLayout = pathHiddenTextObj.AddComponent();
hiddenLayout.minHeight = 25;
- hiddenLayout.flexibleHeight = 75;
- hiddenLayout.minWidth = 400;
+ hiddenLayout.flexibleHeight = 125;
+ hiddenLayout.minWidth = 250;
hiddenLayout.flexibleWidth = 9000;
var hiddenGroup = pathHiddenTextObj.AddComponent();
hiddenGroup.childForceExpandWidth = true;
@@ -297,13 +303,16 @@ namespace UnityExplorer.Inspectors
m_pathInput.textComponent.color = new Color(0.75f, 0.75f, 0.75f);
m_pathInput.textComponent.lineSpacing = 1.5f;
+ m_pathInputRect = m_pathInput.GetComponent();
+ m_hiddenPathRect = m_hiddenPathText.GetComponent();
+
// name row
var nameRowObj = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f));
var nameGroup = nameRowObj.GetComponent();
nameGroup.childForceExpandHeight = false;
nameGroup.childForceExpandWidth = false;
- nameGroup.childControlHeight = false;
+ nameGroup.childControlHeight = true;
nameGroup.childControlWidth = true;
nameGroup.spacing = 5;
var nameRect = nameRowObj.GetComponent();
diff --git a/src/Inspectors/GOInspector/ChildList.cs b/src/Inspectors/GameObjects/ChildList.cs
similarity index 99%
rename from src/Inspectors/GOInspector/ChildList.cs
rename to src/Inspectors/GameObjects/ChildList.cs
index e249be2..c3d31ec 100644
--- a/src/Inspectors/GOInspector/ChildList.cs
+++ b/src/Inspectors/GameObjects/ChildList.cs
@@ -9,7 +9,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Input;
-namespace UnityExplorer.Inspectors.GOInspector
+namespace UnityExplorer.Inspectors.GameObjects
{
public class ChildList
{
diff --git a/src/Inspectors/GOInspector/ComponentList.cs b/src/Inspectors/GameObjects/ComponentList.cs
similarity index 99%
rename from src/Inspectors/GOInspector/ComponentList.cs
rename to src/Inspectors/GameObjects/ComponentList.cs
index 7049308..23b6b6a 100644
--- a/src/Inspectors/GOInspector/ComponentList.cs
+++ b/src/Inspectors/GameObjects/ComponentList.cs
@@ -10,7 +10,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Input;
-namespace UnityExplorer.Inspectors.GOInspector
+namespace UnityExplorer.Inspectors.GameObjects
{
public class ComponentList
{
diff --git a/src/Inspectors/GOInspector/GameObjectControls.cs b/src/Inspectors/GameObjects/GameObjectControls.cs
similarity index 99%
rename from src/Inspectors/GOInspector/GameObjectControls.cs
rename to src/Inspectors/GameObjects/GameObjectControls.cs
index a454f8a..e6008d8 100644
--- a/src/Inspectors/GOInspector/GameObjectControls.cs
+++ b/src/Inspectors/GameObjects/GameObjectControls.cs
@@ -9,7 +9,7 @@ using UnityEngine.UI;
using UnityExplorer.Input;
using UnityExplorer.Unstrip;
-namespace UnityExplorer.Inspectors.GOInspector
+namespace UnityExplorer.Inspectors.GameObjects
{
public class GameObjectControls
{
diff --git a/src/Inspectors/InspectorBase.cs b/src/Inspectors/InspectorBase.cs
index 7440ed1..567ce1a 100644
--- a/src/Inspectors/InspectorBase.cs
+++ b/src/Inspectors/InspectorBase.cs
@@ -8,11 +8,11 @@ namespace UnityExplorer.Inspectors
public abstract class InspectorBase
{
public object Target;
- // just to cache a cast
public UnityEngine.Object UnityTarget;
public abstract string TabLabel { get; }
+ public bool IsActive { get; private set; }
public abstract GameObject Content { get; set; }
public Button tabButton;
public Text tabText;
@@ -33,13 +33,15 @@ namespace UnityExplorer.Inspectors
AddInspectorTab();
}
- public virtual void SetContentActive()
+ public virtual void SetActive()
{
+ this.IsActive = true;
Content?.SetActive(true);
}
- public virtual void SetContentInactive()
+ public virtual void SetInactive()
{
+ this.IsActive = false;
Content?.SetActive(false);
}
@@ -65,11 +67,6 @@ namespace UnityExplorer.Inspectors
GameObject.Destroy(tabGroup);
}
- //if (Content)
- //{
- // GameObject.Destroy(Content);
- //}
-
int thisIndex = -1;
if (InspectorManager.Instance.m_currentInspectors.Contains(this))
{
diff --git a/src/Inspectors/InspectorManager.cs b/src/Inspectors/InspectorManager.cs
index 0dda33d..c0efa93 100644
--- a/src/Inspectors/InspectorManager.cs
+++ b/src/Inspectors/InspectorManager.cs
@@ -8,6 +8,7 @@ using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;
+using UnityExplorer.Inspectors.Reflection;
namespace UnityExplorer.Inspectors
{
@@ -82,23 +83,29 @@ namespace UnityExplorer.Inspectors
InspectorBase inspector;
if (obj is GameObject go)
- {
inspector = new GameObjectInspector(go);
- }
else
- {
inspector = new InstanceInspector(obj);
- }
m_currentInspectors.Add(inspector);
- inspector.SetContentInactive();
-
SetInspectorTab(inspector);
}
public void Inspect(Type type)
{
- // TODO static type inspection
+ foreach (var tab in m_currentInspectors)
+ {
+ if (ReferenceEquals(tab.Target as Type, type))
+ {
+ SetInspectorTab(tab);
+ return;
+ }
+ }
+
+ var inspector = new StaticInspector(type);
+
+ m_currentInspectors.Add(inspector);
+ SetInspectorTab(inspector);
}
public void SetInspectorTab(InspectorBase inspector)
@@ -107,7 +114,7 @@ namespace UnityExplorer.Inspectors
m_activeInspector = inspector;
- inspector.SetContentActive();
+ inspector.SetActive();
Color activeColor = new Color(0, 0.25f, 0, 1);
ColorBlock colors = inspector.tabButton.colors;
@@ -119,11 +126,9 @@ namespace UnityExplorer.Inspectors
public void UnsetInspectorTab()
{
if (m_activeInspector == null)
- {
return;
- }
- m_activeInspector.SetContentInactive();
+ m_activeInspector.SetInactive();
ColorBlock colors = m_activeInspector.tabButton.colors;
colors.normalColor = new Color(0.2f, 0.2f, 0.2f, 1);
diff --git a/src/Inspectors/ReflectionInspector/CacheObject/CacheEnumerated.cs b/src/Inspectors/Reflection/CacheObject/CacheEnumerated.cs
similarity index 93%
rename from src/Inspectors/ReflectionInspector/CacheObject/CacheEnumerated.cs
rename to src/Inspectors/Reflection/CacheObject/CacheEnumerated.cs
index 201f2ea..f978d08 100644
--- a/src/Inspectors/ReflectionInspector/CacheObject/CacheEnumerated.cs
+++ b/src/Inspectors/Reflection/CacheObject/CacheEnumerated.cs
@@ -5,7 +5,7 @@
//using System.Text;
//using UnityExplorer.UI;
-//namespace UnityExplorer.CacheObject
+//namespace UnityExplorer.Inspectors.Reflection
//{
// public class CacheEnumerated : CacheObjectBase
// {
diff --git a/src/Inspectors/Reflection/CacheObject/CacheFactory.cs b/src/Inspectors/Reflection/CacheObject/CacheFactory.cs
new file mode 100644
index 0000000..ffb6ee9
--- /dev/null
+++ b/src/Inspectors/Reflection/CacheObject/CacheFactory.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Reflection;
+using UnityEngine;
+using UnityExplorer.Helpers;
+
+namespace UnityExplorer.Inspectors.Reflection
+{
+ public static class CacheFactory
+ {
+ // Don't think I need these with new structure.
+ // Will possibly need something for CacheEnumerated / InteractiveEnumeration though.
+
+ //public static CacheObjectBase GetCacheObject(object obj)
+ //{
+ // if (obj == null) return null;
+
+ // return GetCacheObject(obj, ReflectionHelpers.GetActualType(obj));
+ //}
+
+ //public static CacheObjectBase GetCacheObject(object obj, Type type)
+ //{
+ // var ret = new CacheObjectBase();
+ // ret.InitValue(obj, type);
+ // return ret;
+ //}
+
+ public static CacheMember GetCacheObject(MemberInfo member, object declaringInstance)
+ {
+ CacheMember ret;
+
+ if (member is MethodInfo mi && CanProcessArgs(mi.GetParameters()))
+ {
+ ret = new CacheMethod(mi, declaringInstance);
+ }
+ else if (member is PropertyInfo pi && CanProcessArgs(pi.GetIndexParameters()))
+ {
+ ret = new CacheProperty(pi, declaringInstance);
+ }
+ else if (member is FieldInfo fi)
+ {
+ ret = new CacheField(fi, declaringInstance);
+ }
+ else
+ {
+ return null;
+ }
+
+ return ret;
+ }
+
+ public static bool CanProcessArgs(ParameterInfo[] parameters)
+ {
+ foreach (var param in parameters)
+ {
+ var pType = param.ParameterType;
+
+ if (pType.IsByRef && pType.HasElementType)
+ {
+ pType = pType.GetElementType();
+ }
+
+ if (pType.IsPrimitive || pType == typeof(string))
+ {
+ continue;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/Inspectors/Reflection/CacheObject/CacheField.cs b/src/Inspectors/Reflection/CacheObject/CacheField.cs
new file mode 100644
index 0000000..c57b9dc
--- /dev/null
+++ b/src/Inspectors/Reflection/CacheObject/CacheField.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+using UnityExplorer.UI;
+using UnityExplorer.Helpers;
+
+namespace UnityExplorer.Inspectors.Reflection
+{
+ public class CacheField : CacheMember
+ {
+ public override bool IsStatic => (MemInfo as FieldInfo).IsStatic;
+
+ public CacheField(FieldInfo fieldInfo, object declaringInstance) : base(fieldInfo, declaringInstance)
+ {
+ base.InitValue(null, fieldInfo.FieldType);
+
+ UpdateValue();
+ }
+
+ public override void UpdateValue()
+ {
+ //if (IValue is InteractiveDictionary iDict)
+ //{
+ // if (!iDict.EnsureDictionaryIsSupported())
+ // {
+ // ReflectionException = "Not supported due to TypeInitializationException";
+ // return;
+ // }
+ //}
+
+ try
+ {
+ var fi = MemInfo as FieldInfo;
+ IValue.Value = fi.GetValue(fi.IsStatic ? null : DeclaringInstance);
+
+ base.UpdateValue();
+ }
+ catch (Exception e)
+ {
+ ReflectionException = ReflectionHelpers.ExceptionToString(e);
+ }
+ }
+
+ public override void SetValue()
+ {
+ var fi = MemInfo as FieldInfo;
+ fi.SetValue(fi.IsStatic ? null : DeclaringInstance, IValue.Value);
+ }
+ }
+}
diff --git a/src/Inspectors/Reflection/CacheObject/CacheMember.cs b/src/Inspectors/Reflection/CacheObject/CacheMember.cs
new file mode 100644
index 0000000..b7910eb
--- /dev/null
+++ b/src/Inspectors/Reflection/CacheObject/CacheMember.cs
@@ -0,0 +1,222 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using UnityEngine;
+using UnityExplorer.UI;
+using UnityExplorer.UI.Shared;
+
+namespace UnityExplorer.Inspectors.Reflection
+{
+ public class CacheMember : CacheObjectBase
+ {
+ public MemberInfo MemInfo { get; set; }
+ public Type DeclaringType { get; set; }
+ public object DeclaringInstance { get; set; }
+
+ public virtual bool IsStatic { get; private set; }
+
+ public override bool HasParameters => m_arguments != null && m_arguments.Length > 0;
+ public override bool IsMember => true;
+
+ public string RichTextName => m_richTextName ?? GetRichTextName();
+ private string m_richTextName;
+
+ public override bool CanWrite => m_canWrite ?? GetCanWrite();
+ private bool? m_canWrite;
+
+ public string ReflectionException { get; set; }
+
+ public bool m_evaluated = false;
+ public bool m_isEvaluating;
+ public ParameterInfo[] m_arguments = new ParameterInfo[0];
+ public string[] m_argumentInput = new string[0];
+
+ public CacheMember(MemberInfo memberInfo, object declaringInstance)
+ {
+ MemInfo = memberInfo;
+ DeclaringType = memberInfo.DeclaringType;
+ DeclaringInstance = declaringInstance;
+ }
+
+ //public virtual void InitMember(MemberInfo member, object declaringInstance)
+ //{
+ // MemInfo = member;
+ // DeclaringInstance = declaringInstance;
+ // DeclaringType = member.DeclaringType;
+ //}
+
+ public override void UpdateValue()
+ {
+ base.UpdateValue();
+ }
+
+ public override void SetValue()
+ {
+ // ...
+ }
+
+ public object[] ParseArguments()
+ {
+ if (m_arguments.Length < 1)
+ {
+ return new object[0];
+ }
+
+ var parsedArgs = new List