Cleanup, use Time.realTimeSinceStartup instead of Time.time, add some stuff

This commit is contained in:
Sinai
2021-05-03 21:02:01 +10:00
parent ad61ff243a
commit 8d9d8f76c2
22 changed files with 321 additions and 198 deletions

View File

@ -61,17 +61,17 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
// label
KeyLabel = UIFactory.CreateLabel(keyGroup, "KeyLabel", "not set (key)", TextAnchor.MiddleLeft);
KeyLabel = UIFactory.CreateLabel(keyGroup, "KeyLabel", "<i>empty</i>", TextAnchor.MiddleLeft);
UIFactory.SetLayoutElement(KeyLabel.gameObject, minWidth: 50, flexibleWidth: 999, minHeight: 30);
// Type label for input field
KeyInputTypeLabel = UIFactory.CreateLabel(keyGroup, "InputTypeLabel", "not set", TextAnchor.MiddleLeft);
KeyInputTypeLabel = UIFactory.CreateLabel(keyGroup, "InputTypeLabel", "<i>null</i>", TextAnchor.MiddleLeft);
UIFactory.SetLayoutElement(KeyInputTypeLabel.gameObject, minWidth: 55, flexibleWidth: 0, minHeight: 30);
// input field
var keyInputObj = UIFactory.CreateInputField(keyGroup, "KeyInput", "not set", out KeyInputField);
var keyInputObj = UIFactory.CreateInputField(keyGroup, "KeyInput", "empty", out KeyInputField);
UIFactory.SetLayoutElement(keyInputObj, minHeight: 30, flexibleHeight: 0, flexibleWidth: 200);
//KeyInputField.lineType = InputField.LineType.MultiLineNewline;
KeyInputField.readOnly = true;

View File

@ -76,9 +76,9 @@ namespace UnityExplorer.UI.Inspectors
return;
}
if (Time.time - timeOfLastUpdate > 1f)
if (timeOfLastUpdate.OccuredEarlierThan(1))
{
timeOfLastUpdate = Time.time;
timeOfLastUpdate = Time.realtimeSinceStartup;
// Refresh children and components
TransformTree.RefreshData(true, false);

View File

@ -6,6 +6,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.UI.Inspectors.CacheObject;
using UnityExplorer.UI.Inspectors.CacheObject.Views;
using UnityExplorer.UI.Panels;
using UnityExplorer.UI.Utility;
using UnityExplorer.UI.Widgets;
@ -82,7 +83,7 @@ namespace UnityExplorer.UI.Inspectors.IValues
CacheEntries(value);
TopLabel.text = $"[{cachedEntries.Count}] {SignatureHighlighter.ParseFullType(type, true)}";
TopLabel.text = $"[{cachedEntries.Count}] {SignatureHighlighter.ParseFullType(type, false)}";
}
@ -196,7 +197,7 @@ namespace UnityExplorer.UI.Inspectors.IValues
minHeight += cell.Rect.rect.height;
}
this.scrollLayout.minHeight = Math.Min(400f, minHeight);
this.scrollLayout.minHeight = Math.Min(InspectorPanel.CurrentPanelHeight - 400f, minHeight);
}
private void SetCellLayout(CacheKeyValuePairCell cell)

View File

@ -6,6 +6,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.UI.Inspectors.CacheObject;
using UnityExplorer.UI.Inspectors.CacheObject.Views;
using UnityExplorer.UI.Panels;
using UnityExplorer.UI.Utility;
using UnityExplorer.UI.Widgets;
@ -36,20 +37,6 @@ namespace UnityExplorer.UI.Inspectors.IValues
base.OnBorrowed(owner);
}
public override void SetLayout()
{
var minHeight = 5f;
foreach (var cell in ListScrollPool.CellPool)
{
if (cell.Enabled)
minHeight += cell.Rect.rect.height;
}
this.scrollLayout.minHeight = Math.Min(400f, minHeight);
}
public override void ReleaseFromOwner()
{
base.ReleaseFromOwner();
@ -85,7 +72,7 @@ namespace UnityExplorer.UI.Inspectors.IValues
CacheEntries(value);
TopLabel.text = $"[{cachedEntries.Count}] {SignatureHighlighter.ParseFullType(type, true)}";
TopLabel.text = $"[{cachedEntries.Count}] {SignatureHighlighter.ParseFullType(type, false)}";
}
//this.ScrollPoolLayout.minHeight = Math.Min(400f, 35f * values.Count);
@ -144,6 +131,19 @@ namespace UnityExplorer.UI.Inspectors.IValues
// List entry scroll pool
public override void SetLayout()
{
var minHeight = 5f;
foreach (var cell in ListScrollPool.CellPool)
{
if (cell.Enabled)
minHeight += cell.Rect.rect.height;
}
this.scrollLayout.minHeight = Math.Min(InspectorPanel.CurrentPanelHeight - 400f, minHeight);
}
public void OnCellBorrowed(CacheListEntryCell cell)
{

View File

@ -72,9 +72,14 @@ namespace UnityExplorer.UI.Inspectors.IValues
public virtual GameObject CreateContent(GameObject parent)
{
UIRoot = UIFactory.CreateUIObject(this.GetType().Name, parent);
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(UIRoot, true, true, true, true, 3, childAlignment: TextAnchor.MiddleLeft);
UIRoot.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(UIRoot, true, true, true, true, 3, childAlignment: TextAnchor.MiddleLeft);
UIFactory.CreateLabel(UIRoot, "Label", "this is an ivalue", TextAnchor.MiddleLeft);
UIFactory.CreateInputField(UIRoot, "InputFIeld", "...", out var input);
UIFactory.SetLayoutElement(input.gameObject, minHeight: 25, flexibleHeight: 500);
input.lineType = InputField.LineType.MultiLineNewline;
input.gameObject.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
return UIRoot;
}

View File

@ -18,7 +18,6 @@ namespace UnityExplorer.UI.Inspectors
{
public class ReflectionInspector : InspectorBase, IPoolDataSource<CacheMemberCell>, ICacheObjectController
{
// TODO
public CacheObjectBase ParentCacheObject { get; set; }
public bool StaticOnly { get; internal set; }
@ -145,9 +144,9 @@ namespace UnityExplorer.UI.Inspectors
return;
}
if (Time.time - timeOfLastUpdate > 1f)
if (timeOfLastUpdate.OccuredEarlierThan(1))
{
timeOfLastUpdate = Time.time;
timeOfLastUpdate = Time.realtimeSinceStartup;
if (AutoUpdateWanted)
UpdateDisplayedMembers();// true);