mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 14:17:51 +08:00
more progress
This commit is contained in:
parent
324d3afa5b
commit
a2a2b09d33
@ -20,14 +20,22 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
public static bool ReferenceEqual(this object objA, object objB)
|
public static bool ReferenceEqual(this object objA, object objB)
|
||||||
{
|
{
|
||||||
if (objA is UnityEngine.Object unityA)
|
if (object.ReferenceEquals(objA, objB))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (objA is UnityEngine.Object unityA && objB is UnityEngine.Object unityB)
|
||||||
{
|
{
|
||||||
var unityB = objB as UnityEngine.Object;
|
if (unityA && unityB && unityA.m_CachedPtr == unityB.m_CachedPtr)
|
||||||
if (unityB && unityA.m_CachedPtr == unityB.m_CachedPtr)
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return object.ReferenceEquals(objA, objB);
|
#if CPP
|
||||||
|
if (objA is Il2CppSystem.Object cppA && objB is Il2CppSystem.Object cppB
|
||||||
|
&& cppA.Pointer == cppB.Pointer)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -11,6 +11,8 @@ namespace UnityExplorer.Tests
|
|||||||
|
|
||||||
public const int ConstantInt = 5;
|
public const int ConstantInt = 5;
|
||||||
|
|
||||||
|
public static byte[] ByteArray = new byte[16];
|
||||||
|
|
||||||
public static string LongString = @"#######################################################################################################
|
public static string LongString = @"#######################################################################################################
|
||||||
###############################################################################################################################
|
###############################################################################################################################
|
||||||
#####################################################################################################################################
|
#####################################################################################################################################
|
||||||
|
@ -55,7 +55,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
|
|||||||
this.FallbackType = returnType;
|
this.FallbackType = returnType;
|
||||||
this.MemberLabelText = SignatureHighlighter.ParseFullSyntax(declaringType, false, member);
|
this.MemberLabelText = SignatureHighlighter.ParseFullSyntax(declaringType, false, member);
|
||||||
this.NameForFiltering = $"{declaringType.Name}.{member.Name}";
|
this.NameForFiltering = $"{declaringType.Name}.{member.Name}";
|
||||||
this.TypeLabelText = SignatureHighlighter.HighlightTypeName(FallbackType, false);
|
this.TypeLabelText = SignatureHighlighter.ParseFullType(FallbackType, false);
|
||||||
this.ValueLabelText = GetValueLabel();
|
this.ValueLabelText = GetValueLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +73,9 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
|
|||||||
{
|
{
|
||||||
TryEvaluate();
|
TryEvaluate();
|
||||||
|
|
||||||
|
if (!Value.IsNullOrDestroyed())
|
||||||
|
Value = Value.TryCast();
|
||||||
|
|
||||||
ProcessOnEvaluate();
|
ProcessOnEvaluate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +123,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
|
|||||||
switch (State)
|
switch (State)
|
||||||
{
|
{
|
||||||
case ValueState.NotEvaluated:
|
case ValueState.NotEvaluated:
|
||||||
return $"<i>{NOT_YET_EVAL} ({SignatureHighlighter.HighlightTypeName(FallbackType, true)})</i>";
|
return $"<i>{NOT_YET_EVAL} ({SignatureHighlighter.ParseFullType(FallbackType, true)})</i>";
|
||||||
case ValueState.Exception:
|
case ValueState.Exception:
|
||||||
return $"<i><color=red>{ReflectionUtility.ReflectionExToString(LastException)}</color></i>";
|
return $"<i><color=red>{ReflectionUtility.ReflectionExToString(LastException)}</color></i>";
|
||||||
case ValueState.Boolean:
|
case ValueState.Boolean:
|
||||||
|
@ -124,7 +124,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
if (!compToStringCache.ContainsKey(type.AssemblyQualifiedName))
|
if (!compToStringCache.ContainsKey(type.AssemblyQualifiedName))
|
||||||
{
|
{
|
||||||
compToStringCache.Add(type.AssemblyQualifiedName,
|
compToStringCache.Add(type.AssemblyQualifiedName,
|
||||||
$"<color={SignatureHighlighter.NAMESPACE}>{type.Namespace}</color>.{SignatureHighlighter.HighlightTypeName(type)}");
|
$"<color={SignatureHighlighter.NAMESPACE}>{type.Namespace}</color>.{SignatureHighlighter.ParseFullType(type)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.Button.ButtonText.text = compToStringCache[type.AssemblyQualifiedName];
|
cell.Button.ButtonText.text = compToStringCache[type.AssemblyQualifiedName];
|
||||||
|
@ -11,14 +11,12 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
public abstract class InspectorBase : IPooledObject
|
public abstract class InspectorBase : IPooledObject
|
||||||
{
|
{
|
||||||
public bool IsActive { get; internal set; }
|
public bool IsActive { get; internal set; }
|
||||||
|
public object InspectorTarget { get; internal set; }
|
||||||
|
|
||||||
public InspectorTab Tab { get; internal set; }
|
public InspectorTab Tab { get; internal set; }
|
||||||
|
|
||||||
public abstract GameObject UIRoot { get; }
|
public abstract GameObject UIRoot { get; }
|
||||||
|
|
||||||
private static readonly Color _enabledTabColor = new Color(0.2f, 0.4f, 0.2f);
|
|
||||||
private static readonly Color _disabledTabColor = new Color(0.25f, 0.25f, 0.25f);
|
|
||||||
|
|
||||||
public float DefaultHeight => -1f;
|
public float DefaultHeight => -1f;
|
||||||
public abstract GameObject CreateContent(GameObject parent);
|
public abstract GameObject CreateContent(GameObject parent);
|
||||||
|
|
||||||
@ -43,14 +41,14 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
public virtual void OnSetActive()
|
public virtual void OnSetActive()
|
||||||
{
|
{
|
||||||
RuntimeProvider.Instance.SetColorBlock(Tab.TabButton.Button, _enabledTabColor, _enabledTabColor * 1.2f);
|
Tab.SetTabColor(true);
|
||||||
UIRoot.SetActive(true);
|
UIRoot.SetActive(true);
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnSetInactive()
|
public virtual void OnSetInactive()
|
||||||
{
|
{
|
||||||
RuntimeProvider.Instance.SetColorBlock(Tab.TabButton.Button, _disabledTabColor, _disabledTabColor * 1.2f);
|
Tab.SetTabColor(false);
|
||||||
UIRoot.SetActive(false);
|
UIRoot.SetActive(false);
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,30 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
obj = obj.TryCast();
|
obj = obj.TryCast();
|
||||||
|
|
||||||
|
if (TryFocusActiveInspector(obj))
|
||||||
|
return;
|
||||||
|
|
||||||
if (obj is GameObject)
|
if (obj is GameObject)
|
||||||
CreateInspector<GameObjectInspector>(obj);
|
CreateInspector<GameObjectInspector>(obj);
|
||||||
else
|
else
|
||||||
CreateInspector<ReflectionInspector>(obj);
|
CreateInspector<ReflectionInspector>(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool TryFocusActiveInspector(object target)
|
||||||
|
{
|
||||||
|
foreach (var inspector in Inspectors)
|
||||||
|
{
|
||||||
|
if (inspector.InspectorTarget.ReferenceEqual(target))
|
||||||
|
{
|
||||||
|
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
|
||||||
|
SetInspectorActive(inspector);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Inspect(Type type)
|
public static void Inspect(Type type)
|
||||||
{
|
{
|
||||||
CreateInspector<ReflectionInspector>(type, true);
|
CreateInspector<ReflectionInspector>(type, true);
|
||||||
@ -52,6 +70,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
{
|
{
|
||||||
var inspector = Pool<T>.Borrow();
|
var inspector = Pool<T>.Borrow();
|
||||||
Inspectors.Add(inspector);
|
Inspectors.Add(inspector);
|
||||||
|
inspector.InspectorTarget = target;
|
||||||
|
|
||||||
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
|
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
|
||||||
inspector.UIRoot.transform.SetParent(InspectorPanel.Instance.ContentHolder.transform, false);
|
inspector.UIRoot.transform.SetParent(InspectorPanel.Instance.ContentHolder.transform, false);
|
||||||
|
@ -21,9 +21,21 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
public ButtonRef CloseButton;
|
public ButtonRef CloseButton;
|
||||||
|
|
||||||
|
private static readonly Color _enabledTabColor = new Color(0.15f, 0.22f, 0.15f);
|
||||||
|
private static readonly Color _disabledTabColor = new Color(0.13f, 0.13f, 0.13f);
|
||||||
|
|
||||||
|
public void SetTabColor(bool active)
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
RuntimeProvider.Instance.SetColorBlock(TabButton.Button, _enabledTabColor, _enabledTabColor * 1.2f);
|
||||||
|
else
|
||||||
|
RuntimeProvider.Instance.SetColorBlock(TabButton.Button, _disabledTabColor, _disabledTabColor * 1.2f);
|
||||||
|
}
|
||||||
|
|
||||||
public GameObject CreateContent(GameObject parent)
|
public GameObject CreateContent(GameObject parent)
|
||||||
{
|
{
|
||||||
uiRoot = UIFactory.CreateHorizontalGroup(parent, "TabObject", true, true, true, true, 0, new Vector4(0, 0, 3, 0));
|
uiRoot = UIFactory.CreateHorizontalGroup(parent, "TabObject", true, true, true, true, 0,
|
||||||
|
new Vector4(0, 0, 3, 0), new Color(0.13f, 0.13f, 0.13f));
|
||||||
UIFactory.SetLayoutElement(uiRoot, minWidth: 185, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(uiRoot, minWidth: 185, flexibleWidth: 0);
|
||||||
uiRoot.AddComponent<Mask>();
|
uiRoot.AddComponent<Mask>();
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
asmText = $"{TargetType.Assembly.GetName().Name} <color=grey><i>(in memory)</i></color>";
|
asmText = $"{TargetType.Assembly.GetName().Name} <color=grey><i>(in memory)</i></color>";
|
||||||
AssemblyText.text = $"<color=grey>Assembly:</color> {asmText}";
|
AssemblyText.text = $"<color=grey>Assembly:</color> {asmText}";
|
||||||
|
|
||||||
Tab.TabText.text = $"{prefix} {SignatureHighlighter.HighlightTypeName(TargetType)}";
|
Tab.TabText.text = $"{prefix} {SignatureHighlighter.ParseFullType(TargetType)}";
|
||||||
|
|
||||||
this.members = CacheMember.GetCacheMembers(Target, TargetType, this);
|
this.members = CacheMember.GetCacheMembers(Target, TargetType, this);
|
||||||
FilterMembers();
|
FilterMembers();
|
||||||
|
@ -70,9 +70,9 @@ namespace UnityExplorer.UI.Panels
|
|||||||
{
|
{
|
||||||
// this.UIRoot.GetComponent<Mask>().enabled = false;
|
// this.UIRoot.GetComponent<Mask>().enabled = false;
|
||||||
|
|
||||||
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(this.content, forceHeight: true, spacing: 10, padLeft: 5, padRight: 5);
|
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(this.content, forceHeight: true, spacing: 4, padLeft: 5, padRight: 5);
|
||||||
|
|
||||||
this.NavbarHolder = UIFactory.CreateGridGroup(this.content, "Navbar", new Vector2(200, 22), new Vector2(4, 2),
|
this.NavbarHolder = UIFactory.CreateGridGroup(this.content, "Navbar", new Vector2(200, 22), new Vector2(4, 4),
|
||||||
new Color(0.12f, 0.12f, 0.12f));
|
new Color(0.12f, 0.12f, 0.12f));
|
||||||
//UIFactory.SetLayoutElement(NavbarHolder, flexibleWidth: 9999, minHeight: 0, preferredHeight: 0, flexibleHeight: 9999);
|
//UIFactory.SetLayoutElement(NavbarHolder, flexibleWidth: 9999, minHeight: 0, preferredHeight: 0, flexibleHeight: 9999);
|
||||||
NavbarHolder.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
NavbarHolder.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||||
|
@ -97,7 +97,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
{
|
{
|
||||||
string text;
|
string text;
|
||||||
if (m_context == SearchContext.StaticClass)
|
if (m_context == SearchContext.StaticClass)
|
||||||
text = SignatureHighlighter.HighlightTypeName(currentResults[index] as Type, true, true);
|
text = SignatureHighlighter.ParseFullType(currentResults[index] as Type, true, true);
|
||||||
else
|
else
|
||||||
text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType());
|
text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType());
|
||||||
|
|
||||||
|
@ -100,6 +100,9 @@ namespace UnityExplorer.UI.Panels
|
|||||||
private Vector2 m_lastResizePos;
|
private Vector2 m_lastResizePos;
|
||||||
|
|
||||||
private bool WasHoveringResize => s_resizeCursorObj.activeInHierarchy;
|
private bool WasHoveringResize => s_resizeCursorObj.activeInHierarchy;
|
||||||
|
|
||||||
|
public static bool ResizePrompting => s_resizeCursorObj && s_resizeCursorObj.activeSelf;
|
||||||
|
|
||||||
private ResizeTypes m_lastResizeHoverType;
|
private ResizeTypes m_lastResizeHoverType;
|
||||||
|
|
||||||
private Rect m_totalResizeRect;
|
private Rect m_totalResizeRect;
|
||||||
@ -140,6 +143,9 @@ namespace UnityExplorer.UI.Panels
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case MouseState.Down:
|
case MouseState.Down:
|
||||||
|
if (inDragPos || inResizePos)
|
||||||
|
UIManager.SetPanelActive(Panel, true);
|
||||||
|
|
||||||
if (inDragPos)
|
if (inDragPos)
|
||||||
{
|
{
|
||||||
if (AllowDragAndResize)
|
if (AllowDragAndResize)
|
||||||
|
@ -9,20 +9,27 @@ using UnityExplorer.Core.Config;
|
|||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Utility;
|
using UnityExplorer.UI.Utility;
|
||||||
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Panels
|
namespace UnityExplorer.UI.Panels
|
||||||
{
|
{
|
||||||
public abstract class UIPanel : UIBehaviourModel
|
public abstract class UIPanel : UIBehaviourModel
|
||||||
{
|
{
|
||||||
// STATIC
|
#region STATIC
|
||||||
|
|
||||||
internal static void InvokeOnPanelsReordered() => OnPanelsReordered?.Invoke();
|
internal static void InvokeOnPanelsReordered() => OnPanelsReordered?.Invoke();
|
||||||
|
|
||||||
public static event Action OnPanelsReordered;
|
public static event Action OnPanelsReordered;
|
||||||
public static event Action OnClickedOutsidePanels;
|
public static event Action OnClickedOutsidePanels;
|
||||||
|
|
||||||
|
internal static readonly List<UIPanel> instances = new List<UIPanel>();
|
||||||
|
internal static readonly Dictionary<int, UIPanel> transformToPanelDict = new Dictionary<int, UIPanel>();
|
||||||
|
|
||||||
public static void UpdateFocus()
|
public static void UpdateFocus()
|
||||||
{
|
{
|
||||||
|
if (PanelDragger.ResizePrompting)
|
||||||
|
return;
|
||||||
|
|
||||||
// if the user is clicking
|
// if the user is clicking
|
||||||
if (InputManager.GetMouseButtonDown(0) || InputManager.GetMouseButtonDown(1))
|
if (InputManager.GetMouseButtonDown(0) || InputManager.GetMouseButtonDown(1))
|
||||||
{
|
{
|
||||||
@ -57,8 +64,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly List<UIPanel> instances = new List<UIPanel>();
|
#endregion
|
||||||
private static readonly Dictionary<int, UIPanel> transformToPanelDict = new Dictionary<int, UIPanel>();
|
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
|
|
||||||
@ -71,10 +77,10 @@ namespace UnityExplorer.UI.Panels
|
|||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
|
|
||||||
public virtual bool ShouldSaveActiveState => true;
|
public virtual bool ShouldSaveActiveState => true;
|
||||||
|
public virtual bool CanDragAndResize => true;
|
||||||
|
public virtual bool NavButtonWanted => true;
|
||||||
|
|
||||||
public virtual bool CanDrag => true;
|
public ButtonRef NavButton;
|
||||||
//public virtual bool CanResize => true;
|
|
||||||
|
|
||||||
public PanelDragger Dragger;
|
public PanelDragger Dragger;
|
||||||
|
|
||||||
public override GameObject UIRoot => uiRoot;
|
public override GameObject UIRoot => uiRoot;
|
||||||
@ -94,6 +100,19 @@ namespace UnityExplorer.UI.Panels
|
|||||||
SaveToConfigManager();
|
SaveToConfigManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetActive(bool active)
|
||||||
|
{
|
||||||
|
base.SetActive(active);
|
||||||
|
|
||||||
|
if (NavButtonWanted)
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
RuntimeProvider.Instance.SetColorBlock(NavButton.Button, UIManager.navButtonEnabledColor, UIManager.navButtonEnabledColor * 1.2f);
|
||||||
|
else
|
||||||
|
RuntimeProvider.Instance.SetColorBlock(NavButton.Button, UIManager.navButtonDisabledColor, UIManager.navButtonDisabledColor * 1.2f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Destroy()
|
public override void Destroy()
|
||||||
{
|
{
|
||||||
instances.Remove(this);
|
instances.Remove(this);
|
||||||
@ -102,22 +121,36 @@ namespace UnityExplorer.UI.Panels
|
|||||||
|
|
||||||
public void ConstructUI()
|
public void ConstructUI()
|
||||||
{
|
{
|
||||||
|
if (NavButtonWanted)
|
||||||
|
{
|
||||||
|
// create navbar button
|
||||||
|
|
||||||
|
NavButton = UIFactory.CreateButton(UIManager.navbarButtonHolder, $"Button_{PanelType}", Name);
|
||||||
|
UIFactory.SetLayoutElement(NavButton.Button.gameObject, minWidth: 118, flexibleWidth: 0);
|
||||||
|
RuntimeProvider.Instance.SetColorBlock(NavButton.Button, UIManager.navButtonDisabledColor, UIManager.navButtonDisabledColor * 1.2f);
|
||||||
|
NavButton.OnClick += () =>
|
||||||
|
{
|
||||||
|
UIManager.TogglePanel(PanelType);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// create core canvas
|
// create core canvas
|
||||||
uiRoot = UIFactory.CreatePanel(Name, out GameObject panelContent);
|
uiRoot = UIFactory.CreatePanel(Name, out GameObject panelContent);
|
||||||
mainPanelRect = this.uiRoot.GetComponent<RectTransform>();
|
mainPanelRect = this.uiRoot.GetComponent<RectTransform>();
|
||||||
content = panelContent;
|
content = panelContent;
|
||||||
|
|
||||||
transformToPanelDict.Add(this.uiRoot.transform.GetInstanceID(), this);
|
int id = this.uiRoot.transform.GetInstanceID();
|
||||||
|
transformToPanelDict.Add(id, this);
|
||||||
|
|
||||||
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(this.uiRoot, true, true, true, true, 0, 0, 0, 0, 0, TextAnchor.UpperLeft);
|
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(this.uiRoot, true, true, true, true, 0, 0, 0, 0, 0, TextAnchor.UpperLeft);
|
||||||
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(content, true, true, true, true, 2, 2, 2, 2, 2, TextAnchor.UpperLeft);
|
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(this.content, true, true, true, true, 2, 2, 2, 2, 2, TextAnchor.UpperLeft);
|
||||||
|
|
||||||
// always apply default pos and anchors (save data may only be partial)
|
// always apply default pos and anchors (save data may only be partial)
|
||||||
SetDefaultPosAndAnchors();
|
SetDefaultPosAndAnchors();
|
||||||
|
|
||||||
// Title bar
|
// Title bar
|
||||||
var titleGroup = UIFactory.CreateHorizontalGroup(content, "TitleBar", false, true, true, true, 2,
|
var titleGroup = UIFactory.CreateHorizontalGroup(content, "TitleBar", false, true, true, true, 2,
|
||||||
new Vector4(2, 2, 2, 2), new Color(0.09f, 0.09f, 0.09f));
|
new Vector4(2, 2, 2, 2), new Color(0.06f, 0.06f, 0.06f));
|
||||||
UIFactory.SetLayoutElement(titleGroup, minHeight: 25, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(titleGroup, minHeight: 25, flexibleHeight: 0);
|
||||||
|
|
||||||
// Title text
|
// Title text
|
||||||
@ -138,7 +171,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
SaveToConfigManager();
|
SaveToConfigManager();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!CanDrag)
|
if (!CanDragAndResize)
|
||||||
titleGroup.SetActive(false);
|
titleGroup.SetActive(false);
|
||||||
|
|
||||||
// Panel dragger
|
// Panel dragger
|
||||||
@ -146,7 +179,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
Dragger = new PanelDragger(titleTxt.GetComponent<RectTransform>(), mainPanelRect);
|
Dragger = new PanelDragger(titleTxt.GetComponent<RectTransform>(), mainPanelRect);
|
||||||
Dragger.OnFinishResize += OnFinishResize;
|
Dragger.OnFinishResize += OnFinishResize;
|
||||||
Dragger.OnFinishDrag += OnFinishDrag;
|
Dragger.OnFinishDrag += OnFinishDrag;
|
||||||
Dragger.AllowDragAndResize = this.CanDrag;
|
Dragger.AllowDragAndResize = this.CanDragAndResize;
|
||||||
//Dragger.CanResize = this.CanResize;
|
//Dragger.CanResize = this.CanResize;
|
||||||
|
|
||||||
// content (abstract)
|
// content (abstract)
|
||||||
|
@ -165,7 +165,7 @@ namespace UnityExplorer.UI
|
|||||||
Image bgImage = contentHolder.AddComponent<Image>();
|
Image bgImage = contentHolder.AddComponent<Image>();
|
||||||
bgImage.type = Image.Type.Filled;
|
bgImage.type = Image.Type.Filled;
|
||||||
if (bgColor == null)
|
if (bgColor == null)
|
||||||
bgImage.color = new Color(0.1f, 0.1f, 0.1f);
|
bgImage.color = new Color(0.06f, 0.06f, 0.06f);
|
||||||
else
|
else
|
||||||
bgImage.color = (Color)bgColor;
|
bgImage.color = (Color)bgColor;
|
||||||
|
|
||||||
|
@ -41,14 +41,13 @@ namespace UnityExplorer.UI
|
|||||||
public static InspectorPanel Inspector { get; private set; }
|
public static InspectorPanel Inspector { get; private set; }
|
||||||
public static AutoCompleter AutoCompleter { get; private set; }
|
public static AutoCompleter AutoCompleter { get; private set; }
|
||||||
|
|
||||||
private static readonly Dictionary<Panels, Button> navButtonDict = new Dictionary<Panels, Button>();
|
// other
|
||||||
internal static readonly Color navButtonEnabledColor = new Color(0.2f, 0.4f, 0.28f);
|
|
||||||
internal static readonly Color navButtonDisabledColor = new Color(0.25f, 0.25f, 0.25f);
|
|
||||||
|
|
||||||
// bundle assets
|
|
||||||
internal static Font ConsoleFont { get; private set; }
|
internal static Font ConsoleFont { get; private set; }
|
||||||
internal static Shader BackupShader { get; private set; }
|
internal static Shader BackupShader { get; private set; }
|
||||||
|
|
||||||
|
internal static readonly Color navButtonEnabledColor = new Color(0.2f, 0.4f, 0.28f);
|
||||||
|
internal static readonly Color navButtonDisabledColor = new Color(0.25f, 0.25f, 0.25f);
|
||||||
|
|
||||||
// main menu toggle
|
// main menu toggle
|
||||||
public static bool ShowMenu
|
public static bool ShowMenu
|
||||||
{
|
{
|
||||||
@ -119,20 +118,25 @@ namespace UnityExplorer.UI
|
|||||||
public static void SetPanelActive(Panels panel, bool active)
|
public static void SetPanelActive(Panels panel, bool active)
|
||||||
{
|
{
|
||||||
var obj = GetPanel(panel);
|
var obj = GetPanel(panel);
|
||||||
obj.SetActive(active);
|
SetPanelActive(obj, active);
|
||||||
if (active)
|
|
||||||
{
|
|
||||||
obj.UIRoot.transform.SetAsLastSibling();
|
|
||||||
UIPanel.InvokeOnPanelsReordered();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (navButtonDict.ContainsKey(panel))
|
public static void SetPanelActive(UIPanel panel, bool active)
|
||||||
{
|
{
|
||||||
var color = active ? navButtonEnabledColor : navButtonDisabledColor;
|
panel.SetActive(active);
|
||||||
RuntimeProvider.Instance.SetColorBlock(navButtonDict[panel], color, color * 1.2f);
|
if (active)
|
||||||
|
{
|
||||||
|
panel.UIRoot.transform.SetAsLastSibling();
|
||||||
|
UIPanel.InvokeOnPanelsReordered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void SetPanelActive(Transform transform, bool value)
|
||||||
|
{
|
||||||
|
if (UIPanel.transformToPanelDict.TryGetValue(transform.GetInstanceID(), out UIPanel panel))
|
||||||
|
SetPanelActive(panel, value);
|
||||||
|
}
|
||||||
|
|
||||||
internal static void InitUI()
|
internal static void InitUI()
|
||||||
{
|
{
|
||||||
LoadBundle();
|
LoadBundle();
|
||||||
@ -197,47 +201,41 @@ namespace UnityExplorer.UI
|
|||||||
PanelHolder.transform.SetAsFirstSibling();
|
PanelHolder.transform.SetAsFirstSibling();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CreateTopNavBar()
|
internal static GameObject navbarButtonHolder;
|
||||||
|
|
||||||
|
private static void CreateTopNavBar()
|
||||||
{
|
{
|
||||||
var panel = UIFactory.CreateUIObject("MainNavbar", CanvasRoot);
|
var navbarPanel = UIFactory.CreateUIObject("MainNavbar", CanvasRoot);
|
||||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(panel, false, true, true, true, 5, 3, 3, 10, 10, TextAnchor.MiddleCenter);
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(navbarPanel, false, true, true, true, 5, 4, 4, 4, 4, TextAnchor.MiddleCenter);
|
||||||
panel.AddComponent<Image>().color = new Color(0.1f, 0.1f, 0.1f);
|
navbarPanel.AddComponent<Image>().color = new Color(0.1f, 0.1f, 0.1f);
|
||||||
var panelRect = panel.GetComponent<RectTransform>();
|
var panelRect = navbarPanel.GetComponent<RectTransform>();
|
||||||
panelRect.pivot = new Vector2(0.5f, 1f);
|
panelRect.pivot = new Vector2(0.5f, 1f);
|
||||||
panelRect.anchorMin = new Vector2(0.5f, 1f);
|
panelRect.anchorMin = new Vector2(0.5f, 1f);
|
||||||
panelRect.anchorMax = new Vector2(0.5f, 1f);
|
panelRect.anchorMax = new Vector2(0.5f, 1f);
|
||||||
panelRect.sizeDelta = new Vector2(900f, 35f);
|
panelRect.sizeDelta = new Vector2(900f, 35f);
|
||||||
|
|
||||||
|
// UnityExplorer title
|
||||||
|
|
||||||
string titleTxt = $"{ExplorerCore.NAME} <i><color=grey>{ExplorerCore.VERSION}</color></i>";
|
string titleTxt = $"{ExplorerCore.NAME} <i><color=grey>{ExplorerCore.VERSION}</color></i>";
|
||||||
var title = UIFactory.CreateLabel(panel, "Title", titleTxt, TextAnchor.MiddleLeft, default, true, 18);
|
var title = UIFactory.CreateLabel(navbarPanel, "Title", titleTxt, TextAnchor.MiddleLeft, default, true, 18);
|
||||||
UIFactory.SetLayoutElement(title.gameObject, minWidth: 240, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(title.gameObject, minWidth: 240, flexibleWidth: 0);// close button
|
||||||
|
|
||||||
CreateNavButton(panel, Panels.ObjectExplorer, "Object Explorer");
|
// Navbar
|
||||||
CreateNavButton(panel, Panels.Inspector, "Inspector");
|
|
||||||
CreateNavButton(panel, Panels.CSConsole, "C# Console");
|
|
||||||
CreateNavButton(panel, Panels.Options, "Options");
|
|
||||||
CreateNavButton(panel, Panels.ConsoleLog, "Console Log");
|
|
||||||
|
|
||||||
// close button
|
navbarButtonHolder = UIFactory.CreateUIObject("NavButtonHolder", navbarPanel);
|
||||||
|
UIFactory.SetLayoutElement(navbarButtonHolder, flexibleHeight: 999, flexibleWidth: 999);
|
||||||
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(navbarButtonHolder, true, true, true, true, 4, 2, 2, 2, 2);
|
||||||
|
|
||||||
var closeBtn = UIFactory.CreateButton(panel, "CloseButton", "X");
|
// Hide menu button
|
||||||
UIFactory.SetLayoutElement(closeBtn.Button.gameObject, minHeight: 25, minWidth: 25, flexibleWidth: 0);
|
|
||||||
|
var closeBtn = UIFactory.CreateButton(navbarPanel, "CloseButton", ConfigManager.Main_Menu_Toggle.Value.ToString());
|
||||||
|
UIFactory.SetLayoutElement(closeBtn.Button.gameObject, minHeight: 25, minWidth: 80, flexibleWidth: 0);
|
||||||
RuntimeProvider.Instance.SetColorBlock(closeBtn.Button, new Color(0.63f, 0.32f, 0.31f),
|
RuntimeProvider.Instance.SetColorBlock(closeBtn.Button, new Color(0.63f, 0.32f, 0.31f),
|
||||||
new Color(0.81f, 0.25f, 0.2f), new Color(0.6f, 0.18f, 0.16f));
|
new Color(0.81f, 0.25f, 0.2f), new Color(0.6f, 0.18f, 0.16f));
|
||||||
|
|
||||||
closeBtn.OnClick += () => { ShowMenu = false; };
|
ConfigManager.Main_Menu_Toggle.OnValueChanged += (KeyCode val) => { closeBtn.ButtonText.text = val.ToString(); };
|
||||||
}
|
|
||||||
|
|
||||||
private static void CreateNavButton(GameObject navbar, Panels panel, string label)
|
closeBtn.OnClick += () => { ShowMenu = false; };
|
||||||
{
|
|
||||||
var button = UIFactory.CreateButton(navbar, $"Button_{panel}", label);
|
|
||||||
UIFactory.SetLayoutElement(button.Button.gameObject, minWidth: 118, flexibleWidth: 0);
|
|
||||||
RuntimeProvider.Instance.SetColorBlock(button.Button, navButtonDisabledColor, navButtonDisabledColor * 1.2f);
|
|
||||||
button.OnClick += () =>
|
|
||||||
{
|
|
||||||
TogglePanel(panel);
|
|
||||||
};
|
|
||||||
navButtonDict.Add(panel, button.Button);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Could be cool, need to investigate properly.
|
// Could be cool, need to investigate properly.
|
||||||
|
@ -63,17 +63,26 @@ namespace UnityExplorer.UI.Utility
|
|||||||
|
|
||||||
syntaxBuilder.Clear();
|
syntaxBuilder.Clear();
|
||||||
|
|
||||||
|
// Namespace
|
||||||
|
|
||||||
if (includeNamespace && !string.IsNullOrEmpty(type.Namespace))
|
if (includeNamespace && !string.IsNullOrEmpty(type.Namespace))
|
||||||
syntaxBuilder.Append($"<color={NAMESPACE}>{type.Namespace}</color>.");
|
syntaxBuilder.Append($"<color={NAMESPACE}>{type.Namespace}</color>.");
|
||||||
|
|
||||||
|
// Declaring type
|
||||||
|
|
||||||
var declaring = type.DeclaringType;
|
var declaring = type.DeclaringType;
|
||||||
while (declaring != null)
|
while (declaring != null)
|
||||||
{
|
{
|
||||||
syntaxBuilder.Append(HighlightTypeName(declaring) + ".");
|
syntaxBuilder.Append(HighlightType(declaring));
|
||||||
|
syntaxBuilder.Append('.');
|
||||||
declaring = declaring.DeclaringType;
|
declaring = declaring.DeclaringType;
|
||||||
}
|
}
|
||||||
|
|
||||||
syntaxBuilder.Append(HighlightTypeName(type));
|
// Highlight the type name
|
||||||
|
|
||||||
|
syntaxBuilder.Append(HighlightType(type));
|
||||||
|
|
||||||
|
// If memberInfo, highlight the member info
|
||||||
|
|
||||||
if (memberInfo != null)
|
if (memberInfo != null)
|
||||||
{
|
{
|
||||||
@ -100,9 +109,7 @@ namespace UnityExplorer.UI.Utility
|
|||||||
return syntaxBuilder.ToString();
|
return syntaxBuilder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Dictionary<string, string> typeToRichType = new Dictionary<string, string>();
|
public static string ParseFullType(Type type, bool includeNamespace = false, bool includeDllName = false)
|
||||||
|
|
||||||
public static string HighlightTypeName(Type type, bool includeNamespace = false, bool includeDllName = false)
|
|
||||||
{
|
{
|
||||||
string ret = HighlightType(type);
|
string ret = HighlightType(type);
|
||||||
|
|
||||||
@ -120,6 +127,8 @@ namespace UnityExplorer.UI.Utility
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, string> typeToRichType = new Dictionary<string, string>();
|
||||||
|
|
||||||
private static string HighlightType(Type type)
|
private static string HighlightType(Type type)
|
||||||
{
|
{
|
||||||
string key = type.ToString();
|
string key = type.ToString();
|
||||||
@ -133,6 +142,7 @@ namespace UnityExplorer.UI.Utility
|
|||||||
{
|
{
|
||||||
isArray = true;
|
isArray = true;
|
||||||
typeName = typeName.Substring(0, typeName.Length - 2);
|
typeName = typeName.Substring(0, typeName.Length - 2);
|
||||||
|
type = type.GetElementType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.IsGenericParameter || (type.HasElementType && type.GetElementType().IsGenericParameter))
|
if (type.IsGenericParameter || (type.HasElementType && type.GetElementType().IsGenericParameter))
|
||||||
@ -194,7 +204,7 @@ namespace UnityExplorer.UI.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
// using HighlightTypeName makes it recursive, so we can parse nested generic args.
|
// using HighlightTypeName makes it recursive, so we can parse nested generic args.
|
||||||
ret += HighlightTypeName(args[i]);
|
ret += ParseFullType(args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -20,6 +20,22 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
|||||||
|
|
||||||
// Instance
|
// Instance
|
||||||
|
|
||||||
|
public override string Name => "AutoCompleter";
|
||||||
|
public override UIManager.Panels PanelType => UIManager.Panels.AutoCompleter;
|
||||||
|
|
||||||
|
public override bool CanDragAndResize => false;
|
||||||
|
public override bool ShouldSaveActiveState => false;
|
||||||
|
public override bool NavButtonWanted => false;
|
||||||
|
|
||||||
|
public ISuggestionProvider CurrentHandler { get; private set; }
|
||||||
|
|
||||||
|
public ButtonListSource<Suggestion> dataHandler;
|
||||||
|
public ScrollPool<ButtonCell> scrollPool;
|
||||||
|
|
||||||
|
private List<Suggestion> suggestions = new List<Suggestion>();
|
||||||
|
|
||||||
|
private int lastCaretPos;
|
||||||
|
|
||||||
public AutoCompleter()
|
public AutoCompleter()
|
||||||
{
|
{
|
||||||
OnPanelsReordered += UIPanel_OnPanelsReordered;
|
OnPanelsReordered += UIPanel_OnPanelsReordered;
|
||||||
@ -51,20 +67,6 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Name => "AutoCompleter";
|
|
||||||
public override UIManager.Panels PanelType => UIManager.Panels.AutoCompleter;
|
|
||||||
|
|
||||||
public override bool CanDrag => false;
|
|
||||||
|
|
||||||
public ISuggestionProvider CurrentHandler { get; private set; }
|
|
||||||
|
|
||||||
public ButtonListSource<Suggestion> dataHandler;
|
|
||||||
public ScrollPool<ButtonCell> scrollPool;
|
|
||||||
|
|
||||||
private List<Suggestion> suggestions = new List<Suggestion>();
|
|
||||||
|
|
||||||
private int lastCaretPos;
|
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
if (!UIRoot || !UIRoot.activeSelf)
|
if (!UIRoot || !UIRoot.activeSelf)
|
||||||
|
@ -210,9 +210,11 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
// If we somehow reached the end and didn't find the data index...
|
// If we somehow reached the end and didn't find the data index...
|
||||||
if (i == rangeCache.Count - 1)
|
if (i == rangeCache.Count - 1)
|
||||||
{
|
{
|
||||||
// This should never happen. We might be in a rebuild right now so don't
|
if (!inRebuild)
|
||||||
// rebuild again, we could overflow the stack. Just log it.
|
RebuildCache();
|
||||||
ExplorerCore.LogWarning($"DataHeightCache: Looking for range index of data {dataIndex} but reached the end and didn't find it.");
|
else
|
||||||
|
ExplorerCore.LogWarning($"DataHeightCache: Looking for range index of data {dataIndex} but " +
|
||||||
|
$"reached the end and didn't find it. Count: {rangeCache.Count}, last index: {rangeCache[rangeCache.Count - 1]}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user