mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 22:07:48 +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)
|
||||
{
|
||||
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 (unityB && unityA.m_CachedPtr == unityB.m_CachedPtr)
|
||||
if (unityA && unityB && unityA.m_CachedPtr == unityB.m_CachedPtr)
|
||||
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>
|
||||
|
@ -11,6 +11,8 @@ namespace UnityExplorer.Tests
|
||||
|
||||
public const int ConstantInt = 5;
|
||||
|
||||
public static byte[] ByteArray = new byte[16];
|
||||
|
||||
public static string LongString = @"#######################################################################################################
|
||||
###############################################################################################################################
|
||||
#####################################################################################################################################
|
||||
|
@ -55,7 +55,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
|
||||
this.FallbackType = returnType;
|
||||
this.MemberLabelText = SignatureHighlighter.ParseFullSyntax(declaringType, false, member);
|
||||
this.NameForFiltering = $"{declaringType.Name}.{member.Name}";
|
||||
this.TypeLabelText = SignatureHighlighter.HighlightTypeName(FallbackType, false);
|
||||
this.TypeLabelText = SignatureHighlighter.ParseFullType(FallbackType, false);
|
||||
this.ValueLabelText = GetValueLabel();
|
||||
}
|
||||
|
||||
@ -73,6 +73,9 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
|
||||
{
|
||||
TryEvaluate();
|
||||
|
||||
if (!Value.IsNullOrDestroyed())
|
||||
Value = Value.TryCast();
|
||||
|
||||
ProcessOnEvaluate();
|
||||
}
|
||||
|
||||
@ -120,7 +123,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
|
||||
switch (State)
|
||||
{
|
||||
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:
|
||||
return $"<i><color=red>{ReflectionUtility.ReflectionExToString(LastException)}</color></i>";
|
||||
case ValueState.Boolean:
|
||||
|
@ -124,7 +124,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
if (!compToStringCache.ContainsKey(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];
|
||||
|
@ -11,14 +11,12 @@ namespace UnityExplorer.UI.Inspectors
|
||||
public abstract class InspectorBase : IPooledObject
|
||||
{
|
||||
public bool IsActive { get; internal set; }
|
||||
public object InspectorTarget { get; internal set; }
|
||||
|
||||
public InspectorTab Tab { get; internal set; }
|
||||
|
||||
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 abstract GameObject CreateContent(GameObject parent);
|
||||
|
||||
@ -43,14 +41,14 @@ namespace UnityExplorer.UI.Inspectors
|
||||
|
||||
public virtual void OnSetActive()
|
||||
{
|
||||
RuntimeProvider.Instance.SetColorBlock(Tab.TabButton.Button, _enabledTabColor, _enabledTabColor * 1.2f);
|
||||
Tab.SetTabColor(true);
|
||||
UIRoot.SetActive(true);
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
public virtual void OnSetInactive()
|
||||
{
|
||||
RuntimeProvider.Instance.SetColorBlock(Tab.TabButton.Button, _disabledTabColor, _disabledTabColor * 1.2f);
|
||||
Tab.SetTabColor(false);
|
||||
UIRoot.SetActive(false);
|
||||
IsActive = false;
|
||||
}
|
||||
|
@ -23,12 +23,30 @@ namespace UnityExplorer.UI.Inspectors
|
||||
return;
|
||||
|
||||
obj = obj.TryCast();
|
||||
|
||||
if (TryFocusActiveInspector(obj))
|
||||
return;
|
||||
|
||||
if (obj is GameObject)
|
||||
CreateInspector<GameObjectInspector>(obj);
|
||||
else
|
||||
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)
|
||||
{
|
||||
CreateInspector<ReflectionInspector>(type, true);
|
||||
@ -52,6 +70,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
{
|
||||
var inspector = Pool<T>.Borrow();
|
||||
Inspectors.Add(inspector);
|
||||
inspector.InspectorTarget = target;
|
||||
|
||||
UIManager.SetPanelActive(UIManager.Panels.Inspector, true);
|
||||
inspector.UIRoot.transform.SetParent(InspectorPanel.Instance.ContentHolder.transform, false);
|
||||
|
@ -21,9 +21,21 @@ namespace UnityExplorer.UI.Inspectors
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
uiRoot.AddComponent<Mask>();
|
||||
|
||||
|
@ -82,7 +82,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
asmText = $"{TargetType.Assembly.GetName().Name} <color=grey><i>(in memory)</i></color>";
|
||||
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);
|
||||
FilterMembers();
|
||||
|
@ -70,9 +70,9 @@ namespace UnityExplorer.UI.Panels
|
||||
{
|
||||
// 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));
|
||||
//UIFactory.SetLayoutElement(NavbarHolder, flexibleWidth: 9999, minHeight: 0, preferredHeight: 0, flexibleHeight: 9999);
|
||||
NavbarHolder.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
@ -97,7 +97,7 @@ namespace UnityExplorer.UI.Panels
|
||||
{
|
||||
string text;
|
||||
if (m_context == SearchContext.StaticClass)
|
||||
text = SignatureHighlighter.HighlightTypeName(currentResults[index] as Type, true, true);
|
||||
text = SignatureHighlighter.ParseFullType(currentResults[index] as Type, true, true);
|
||||
else
|
||||
text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType());
|
||||
|
||||
|
@ -100,6 +100,9 @@ namespace UnityExplorer.UI.Panels
|
||||
private Vector2 m_lastResizePos;
|
||||
|
||||
private bool WasHoveringResize => s_resizeCursorObj.activeInHierarchy;
|
||||
|
||||
public static bool ResizePrompting => s_resizeCursorObj && s_resizeCursorObj.activeSelf;
|
||||
|
||||
private ResizeTypes m_lastResizeHoverType;
|
||||
|
||||
private Rect m_totalResizeRect;
|
||||
@ -140,6 +143,9 @@ namespace UnityExplorer.UI.Panels
|
||||
switch (state)
|
||||
{
|
||||
case MouseState.Down:
|
||||
if (inDragPos || inResizePos)
|
||||
UIManager.SetPanelActive(Panel, true);
|
||||
|
||||
if (inDragPos)
|
||||
{
|
||||
if (AllowDragAndResize)
|
||||
|
@ -9,20 +9,27 @@ using UnityExplorer.Core.Config;
|
||||
using UnityExplorer.Core.Input;
|
||||
using UnityExplorer.UI.Models;
|
||||
using UnityExplorer.UI.Utility;
|
||||
using UnityExplorer.UI.Widgets;
|
||||
|
||||
namespace UnityExplorer.UI.Panels
|
||||
{
|
||||
public abstract class UIPanel : UIBehaviourModel
|
||||
{
|
||||
// STATIC
|
||||
#region STATIC
|
||||
|
||||
internal static void InvokeOnPanelsReordered() => OnPanelsReordered?.Invoke();
|
||||
|
||||
public static event Action OnPanelsReordered;
|
||||
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()
|
||||
{
|
||||
if (PanelDragger.ResizePrompting)
|
||||
return;
|
||||
|
||||
// if the user is clicking
|
||||
if (InputManager.GetMouseButtonDown(0) || InputManager.GetMouseButtonDown(1))
|
||||
{
|
||||
@ -57,8 +64,7 @@ namespace UnityExplorer.UI.Panels
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly List<UIPanel> instances = new List<UIPanel>();
|
||||
private static readonly Dictionary<int, UIPanel> transformToPanelDict = new Dictionary<int, UIPanel>();
|
||||
#endregion
|
||||
|
||||
// INSTANCE
|
||||
|
||||
@ -71,10 +77,10 @@ namespace UnityExplorer.UI.Panels
|
||||
public abstract string Name { get; }
|
||||
|
||||
public virtual bool ShouldSaveActiveState => true;
|
||||
public virtual bool CanDragAndResize => true;
|
||||
public virtual bool NavButtonWanted => true;
|
||||
|
||||
public virtual bool CanDrag => true;
|
||||
//public virtual bool CanResize => true;
|
||||
|
||||
public ButtonRef NavButton;
|
||||
public PanelDragger Dragger;
|
||||
|
||||
public override GameObject UIRoot => uiRoot;
|
||||
@ -94,6 +100,19 @@ namespace UnityExplorer.UI.Panels
|
||||
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()
|
||||
{
|
||||
instances.Remove(this);
|
||||
@ -102,22 +121,36 @@ namespace UnityExplorer.UI.Panels
|
||||
|
||||
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
|
||||
uiRoot = UIFactory.CreatePanel(Name, out GameObject panelContent);
|
||||
mainPanelRect = this.uiRoot.GetComponent<RectTransform>();
|
||||
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>(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)
|
||||
SetDefaultPosAndAnchors();
|
||||
|
||||
// Title bar
|
||||
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);
|
||||
|
||||
// Title text
|
||||
@ -138,7 +171,7 @@ namespace UnityExplorer.UI.Panels
|
||||
SaveToConfigManager();
|
||||
};
|
||||
|
||||
if (!CanDrag)
|
||||
if (!CanDragAndResize)
|
||||
titleGroup.SetActive(false);
|
||||
|
||||
// Panel dragger
|
||||
@ -146,7 +179,7 @@ namespace UnityExplorer.UI.Panels
|
||||
Dragger = new PanelDragger(titleTxt.GetComponent<RectTransform>(), mainPanelRect);
|
||||
Dragger.OnFinishResize += OnFinishResize;
|
||||
Dragger.OnFinishDrag += OnFinishDrag;
|
||||
Dragger.AllowDragAndResize = this.CanDrag;
|
||||
Dragger.AllowDragAndResize = this.CanDragAndResize;
|
||||
//Dragger.CanResize = this.CanResize;
|
||||
|
||||
// content (abstract)
|
||||
|
@ -165,7 +165,7 @@ namespace UnityExplorer.UI
|
||||
Image bgImage = contentHolder.AddComponent<Image>();
|
||||
bgImage.type = Image.Type.Filled;
|
||||
if (bgColor == null)
|
||||
bgImage.color = new Color(0.1f, 0.1f, 0.1f);
|
||||
bgImage.color = new Color(0.06f, 0.06f, 0.06f);
|
||||
else
|
||||
bgImage.color = (Color)bgColor;
|
||||
|
||||
|
@ -36,19 +36,18 @@ namespace UnityExplorer.UI
|
||||
|
||||
// panels
|
||||
internal static GameObject PanelHolder { get; private set; }
|
||||
|
||||
|
||||
public static ObjectExplorer Explorer { get; private set; }
|
||||
public static InspectorPanel Inspector { get; private set; }
|
||||
public static AutoCompleter AutoCompleter { get; private set; }
|
||||
|
||||
private static readonly Dictionary<Panels, Button> navButtonDict = new Dictionary<Panels, Button>();
|
||||
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
|
||||
// other
|
||||
internal static Font ConsoleFont { 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
|
||||
public static bool ShowMenu
|
||||
{
|
||||
@ -119,18 +118,23 @@ namespace UnityExplorer.UI
|
||||
public static void SetPanelActive(Panels panel, bool active)
|
||||
{
|
||||
var obj = GetPanel(panel);
|
||||
obj.SetActive(active);
|
||||
SetPanelActive(obj, active);
|
||||
}
|
||||
|
||||
public static void SetPanelActive(UIPanel panel, bool active)
|
||||
{
|
||||
panel.SetActive(active);
|
||||
if (active)
|
||||
{
|
||||
obj.UIRoot.transform.SetAsLastSibling();
|
||||
panel.UIRoot.transform.SetAsLastSibling();
|
||||
UIPanel.InvokeOnPanelsReordered();
|
||||
}
|
||||
}
|
||||
|
||||
if (navButtonDict.ContainsKey(panel))
|
||||
{
|
||||
var color = active ? navButtonEnabledColor : navButtonDisabledColor;
|
||||
RuntimeProvider.Instance.SetColorBlock(navButtonDict[panel], color, color * 1.2f);
|
||||
}
|
||||
internal static void SetPanelActive(Transform transform, bool value)
|
||||
{
|
||||
if (UIPanel.transformToPanelDict.TryGetValue(transform.GetInstanceID(), out UIPanel panel))
|
||||
SetPanelActive(panel, value);
|
||||
}
|
||||
|
||||
internal static void InitUI()
|
||||
@ -197,47 +201,41 @@ namespace UnityExplorer.UI
|
||||
PanelHolder.transform.SetAsFirstSibling();
|
||||
}
|
||||
|
||||
public static void CreateTopNavBar()
|
||||
internal static GameObject navbarButtonHolder;
|
||||
|
||||
private static void CreateTopNavBar()
|
||||
{
|
||||
var panel = UIFactory.CreateUIObject("MainNavbar", CanvasRoot);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(panel, false, true, true, true, 5, 3, 3, 10, 10, TextAnchor.MiddleCenter);
|
||||
panel.AddComponent<Image>().color = new Color(0.1f, 0.1f, 0.1f);
|
||||
var panelRect = panel.GetComponent<RectTransform>();
|
||||
var navbarPanel = UIFactory.CreateUIObject("MainNavbar", CanvasRoot);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(navbarPanel, false, true, true, true, 5, 4, 4, 4, 4, TextAnchor.MiddleCenter);
|
||||
navbarPanel.AddComponent<Image>().color = new Color(0.1f, 0.1f, 0.1f);
|
||||
var panelRect = navbarPanel.GetComponent<RectTransform>();
|
||||
panelRect.pivot = new Vector2(0.5f, 1f);
|
||||
panelRect.anchorMin = new Vector2(0.5f, 1f);
|
||||
panelRect.anchorMax = new Vector2(0.5f, 1f);
|
||||
panelRect.sizeDelta = new Vector2(900f, 35f);
|
||||
|
||||
// UnityExplorer title
|
||||
|
||||
string titleTxt = $"{ExplorerCore.NAME} <i><color=grey>{ExplorerCore.VERSION}</color></i>";
|
||||
var title = UIFactory.CreateLabel(panel, "Title", titleTxt, TextAnchor.MiddleLeft, default, true, 18);
|
||||
UIFactory.SetLayoutElement(title.gameObject, minWidth: 240, flexibleWidth: 0);
|
||||
var title = UIFactory.CreateLabel(navbarPanel, "Title", titleTxt, TextAnchor.MiddleLeft, default, true, 18);
|
||||
UIFactory.SetLayoutElement(title.gameObject, minWidth: 240, flexibleWidth: 0);// close button
|
||||
|
||||
CreateNavButton(panel, Panels.ObjectExplorer, "Object Explorer");
|
||||
CreateNavButton(panel, Panels.Inspector, "Inspector");
|
||||
CreateNavButton(panel, Panels.CSConsole, "C# Console");
|
||||
CreateNavButton(panel, Panels.Options, "Options");
|
||||
CreateNavButton(panel, Panels.ConsoleLog, "Console Log");
|
||||
// Navbar
|
||||
|
||||
// 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");
|
||||
UIFactory.SetLayoutElement(closeBtn.Button.gameObject, minHeight: 25, minWidth: 25, flexibleWidth: 0);
|
||||
// Hide menu button
|
||||
|
||||
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),
|
||||
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)
|
||||
{
|
||||
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);
|
||||
closeBtn.OnClick += () => { ShowMenu = false; };
|
||||
}
|
||||
|
||||
// Could be cool, need to investigate properly.
|
||||
|
@ -63,17 +63,26 @@ namespace UnityExplorer.UI.Utility
|
||||
|
||||
syntaxBuilder.Clear();
|
||||
|
||||
// Namespace
|
||||
|
||||
if (includeNamespace && !string.IsNullOrEmpty(type.Namespace))
|
||||
syntaxBuilder.Append($"<color={NAMESPACE}>{type.Namespace}</color>.");
|
||||
|
||||
// Declaring type
|
||||
|
||||
var declaring = type.DeclaringType;
|
||||
while (declaring != null)
|
||||
{
|
||||
syntaxBuilder.Append(HighlightTypeName(declaring) + ".");
|
||||
syntaxBuilder.Append(HighlightType(declaring));
|
||||
syntaxBuilder.Append('.');
|
||||
declaring = declaring.DeclaringType;
|
||||
}
|
||||
|
||||
syntaxBuilder.Append(HighlightTypeName(type));
|
||||
// Highlight the type name
|
||||
|
||||
syntaxBuilder.Append(HighlightType(type));
|
||||
|
||||
// If memberInfo, highlight the member info
|
||||
|
||||
if (memberInfo != null)
|
||||
{
|
||||
@ -100,9 +109,7 @@ namespace UnityExplorer.UI.Utility
|
||||
return syntaxBuilder.ToString();
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, string> typeToRichType = new Dictionary<string, string>();
|
||||
|
||||
public static string HighlightTypeName(Type type, bool includeNamespace = false, bool includeDllName = false)
|
||||
public static string ParseFullType(Type type, bool includeNamespace = false, bool includeDllName = false)
|
||||
{
|
||||
string ret = HighlightType(type);
|
||||
|
||||
@ -120,6 +127,8 @@ namespace UnityExplorer.UI.Utility
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, string> typeToRichType = new Dictionary<string, string>();
|
||||
|
||||
private static string HighlightType(Type type)
|
||||
{
|
||||
string key = type.ToString();
|
||||
@ -133,6 +142,7 @@ namespace UnityExplorer.UI.Utility
|
||||
{
|
||||
isArray = true;
|
||||
typeName = typeName.Substring(0, typeName.Length - 2);
|
||||
type = type.GetElementType();
|
||||
}
|
||||
|
||||
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.
|
||||
ret += HighlightTypeName(args[i]);
|
||||
ret += ParseFullType(args[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -20,6 +20,22 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
|
||||
// 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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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 (i == rangeCache.Count - 1)
|
||||
{
|
||||
// This should never happen. We might be in a rebuild right now so don't
|
||||
// rebuild again, we could overflow the stack. Just log it.
|
||||
ExplorerCore.LogWarning($"DataHeightCache: Looking for range index of data {dataIndex} but reached the end and didn't find it.");
|
||||
if (!inRebuild)
|
||||
RebuildCache();
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user