diff --git a/src/UI/CacheObject/CacheMember.cs b/src/UI/CacheObject/CacheMember.cs index 5fb203d..605b86e 100644 --- a/src/UI/CacheObject/CacheMember.cs +++ b/src/UI/CacheObject/CacheMember.cs @@ -77,9 +77,6 @@ namespace UnityExplorer.UI.CacheObject public override void TrySetUserValue(object value) { - if (State == ValueState.String) - ReflectionProvider.Instance.BoxStringToType(ref value, FallbackType); - TrySetValue(value); Evaluate(); diff --git a/src/UI/CacheObject/CacheObjectBase.cs b/src/UI/CacheObject/CacheObjectBase.cs index 23aa9c1..3fb9c1f 100644 --- a/src/UI/CacheObject/CacheObjectBase.cs +++ b/src/UI/CacheObject/CacheObjectBase.cs @@ -65,7 +65,6 @@ namespace UnityExplorer.UI.CacheObject protected const string NOT_YET_EVAL = "Not yet evaluated"; - public virtual void ReleasePooledObjects() { if (this.IValue != null) @@ -97,7 +96,10 @@ namespace UnityExplorer.UI.CacheObject public void SetUserValue(object value) { - value = value.TryCast(FallbackType); + if (State == ValueState.String) + ReflectionProvider.Instance.BoxStringToType(ref value, FallbackType); + else + value = value.TryCast(FallbackType); TrySetUserValue(value); } diff --git a/src/UI/CacheObject/Views/CacheObjectCell.cs b/src/UI/CacheObject/Views/CacheObjectCell.cs index a50f798..14ae4dc 100644 --- a/src/UI/CacheObject/Views/CacheObjectCell.cs +++ b/src/UI/CacheObject/Views/CacheObjectCell.cs @@ -97,9 +97,6 @@ namespace UnityExplorer.UI.CacheObject.Views protected abstract void ConstructEvaluateHolder(GameObject parent); - // protected abstract void ConstructUpdateToggle(GameObject parent); - - // Todo could create these as needed maybe, just need to make sure the transform order is correct. public virtual GameObject CreateContent(GameObject parent) { @@ -111,11 +108,6 @@ namespace UnityExplorer.UI.CacheObject.Views UIFactory.SetLayoutElement(UIRoot, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600); UIRoot.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize; - //var content = UIFactory.CreateUIObject("Content", UIRoot); - //UIFactory.SetLayoutGroup(content, true, false, true, true, 2, 0); - //UIFactory.SetLayoutElement(content, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600); - //content.AddComponent().verticalFit = ContentSizeFitter.FitMode.PreferredSize; - var horiRow = UIFactory.CreateUIObject("HoriGroup", UIRoot); UIFactory.SetLayoutElement(horiRow, minHeight: 29, flexibleHeight: 150, flexibleWidth: 9999); UIFactory.SetLayoutGroup(horiRow, false, false, true, true, 5, 2, childAlignment: TextAnchor.UpperLeft); diff --git a/src/UI/IValues/InteractiveDictionary.cs b/src/UI/IValues/InteractiveDictionary.cs index eccebbf..db85733 100644 --- a/src/UI/IValues/InteractiveDictionary.cs +++ b/src/UI/IValues/InteractiveDictionary.cs @@ -57,7 +57,10 @@ namespace UnityExplorer.UI.IValues values.Clear(); foreach (var entry in cachedEntries) + { + entry.UnlinkFromView(); entry.ReleasePooledObjects(); + } cachedEntries.Clear(); } @@ -166,10 +169,15 @@ namespace UnityExplorer.UI.IValues var entry = cachedEntries[index]; - if (cell.Occupant != null && entry != cell.Occupant) + if (entry.CellView != null && entry.CellView != cell) + entry.UnlinkFromView(); + + if (cell.Occupant != null && cell.Occupant != entry) cell.Occupant.UnlinkFromView(); - entry.SetView(cell); + if (entry.CellView != cell) + entry.SetView(cell); + entry.SetDataToCell(cell); SetCellLayout(cell); diff --git a/src/UI/IValues/InteractiveList.cs b/src/UI/IValues/InteractiveList.cs index a236d2e..6e34a93 100644 --- a/src/UI/IValues/InteractiveList.cs +++ b/src/UI/IValues/InteractiveList.cs @@ -163,10 +163,15 @@ namespace UnityExplorer.UI.IValues var entry = cachedEntries[index]; - if (cell.Occupant != null && entry != cell.Occupant) + if (entry.CellView != null && entry.CellView != cell) + entry.UnlinkFromView(); + + if (cell.Occupant != null && cell.Occupant != entry) cell.Occupant.UnlinkFromView(); - entry.SetView(cell); + if (entry.CellView != cell) + entry.SetView(cell); + entry.SetDataToCell(cell); } diff --git a/src/UI/Inspectors/ListInspector.cs b/src/UI/Inspectors/ListInspector.cs deleted file mode 100644 index daa268c..0000000 --- a/src/UI/Inspectors/ListInspector.cs +++ /dev/null @@ -1,197 +0,0 @@ -//using System; -//using System.Collections; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using UnityEngine; -//using UnityEngine.UI; -//using UnityExplorer.UI.CacheObject; -//using UnityExplorer.UI.CacheObject.Views; -//using UnityExplorer.UI.Utility; -//using UnityExplorer.UI.Widgets; - -//namespace UnityExplorer.UI.Inspectors -//{ -// // TODO -// // - set fallback type from generic arguments -// // - handle setting through IList -// // - handle il2cpp lists - -// public class ListInspector : InspectorBase, IPoolDataSource, ICacheObjectController -// { -// // TODO -// public CacheObjectBase ParentCacheObject { get; set; } - -// public Type TargetType { get; private set; } - -// public bool CanWrite => RefIList != null && !RefIList.IsReadOnly; - -// public Type EntryType; -// public IEnumerable RefIEnumerable; -// public IList RefIList; - -// public int ItemCount => values.Count; -// private readonly List values = new List(); -// private readonly List cachedEntries = new List(); - -// public ScrollPool ListScrollPool { get; private set; } - -// public LayoutElement ScrollPoolLayout; -// public Text TopLabel; - -// public override void OnBorrowedFromPool(object target) -// { -// base.OnBorrowedFromPool(target); - -// var type = target.GetActualType(); -// if (type.IsGenericType) -// EntryType = type.GetGenericArguments()[0]; -// else -// EntryType = typeof(object); - -// // Set tab - -// Tab.TabText.text = $"[L] {SignatureHighlighter.ParseFullType(type, false)}"; - -// // Get cache entries - -// CacheEntries(target); - -// TopLabel.text = $"{cachedEntries.Count} entries"; - -// this.ListScrollPool.Refresh(true, false); -// } - -// public override void OnReturnToPool() -// { -// base.OnReturnToPool(); - -// values.Clear(); - -// foreach (var entry in cachedEntries) -// entry.ReleasePooledObjects(); - -// cachedEntries.Clear(); -// } - -// public override void Update() -// { -// // ... -// } - -// protected override void OnCloseClicked() -// { -// InspectorManager.ReleaseInspector(this); -// } - -// private void CacheEntries(object value) -// { -// RefIEnumerable = value as IEnumerable; -// RefIList = value as IList; - -// if (RefIEnumerable == null) -// { -// // todo il2cpp ...? -// } - -// values.Clear(); -// int idx = 0; -// foreach (var entry in RefIEnumerable) -// { -// values.Add(entry); - -// // If list count increased, create new cache entries -// CacheListEntry cache; -// if (idx >= cachedEntries.Count) -// { -// cache = new CacheListEntry(); -// cache.SetListOwner(this, idx); -// cachedEntries.Add(cache); -// } -// else -// cache = cachedEntries[idx]; - -// cache.Initialize(this.EntryType); -// cache.SetValueFromSource(entry); -// idx++; -// } - -// // Remove excess cached entries if list count decreased -// if (cachedEntries.Count > values.Count) -// { -// for (int i = cachedEntries.Count - 1; i >= values.Count; i--) -// { -// var cache = cachedEntries[i]; -// if (cache.CellView != null) -// { -// cache.CellView.Occupant = null; -// cache.CellView = null; -// } -// cache.ReleasePooledObjects(); -// cachedEntries.RemoveAt(i); -// } -// } -// } - -// // List entry scroll pool - -// public void OnCellBorrowed(CacheListEntryCell cell) -// { -// cell.ListOwner = this; -// } - -// public void SetCell(CacheListEntryCell cell, int index) -// { -// if (index < 0 || index >= cachedEntries.Count) -// { -// if (cell.Occupant != null) -// { -// cell.Occupant.CellView = null; -// cell.Occupant = null; -// } - -// cell.Disable(); -// return; -// } - -// var entry = cachedEntries[index]; - -// if (entry != cell.Occupant) -// { -// if (cell.Occupant != null) -// { -// cell.Occupant.HideIValue(); -// cell.Occupant.CellView = null; -// cell.Occupant = null; -// } - -// cell.Occupant = entry; -// entry.CellView = cell; -// } - -// entry.SetCell(cell); -// } - -// public override GameObject CreateContent(GameObject parent) -// { -// UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveList", true, true, true, true, 2, new Vector4(4, 4, 4, 4), -// new Color(0.05f, 0.05f, 0.05f)); - -// UIFactory.SetLayoutElement(UIRoot, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 600); - -// // Entries label - -// TopLabel = UIFactory.CreateLabel(UIRoot, "EntryLabel", "not set", TextAnchor.MiddleLeft); - -// // entry scroll pool - -// ListScrollPool = UIFactory.CreateScrollPool(UIRoot, "EntryList", out GameObject scrollObj, -// out GameObject _, new Color(0.09f, 0.09f, 0.09f)); -// UIFactory.SetLayoutElement(scrollObj, minHeight: 25, flexibleHeight: 9999); -// ListScrollPool.Initialize(this); -// ScrollPoolLayout = scrollObj.GetComponent(); - -// return UIRoot; -// } -// } -//} diff --git a/src/UI/Inspectors/ReflectionInspector.cs b/src/UI/Inspectors/ReflectionInspector.cs index e83881b..1bfabbb 100644 --- a/src/UI/Inspectors/ReflectionInspector.cs +++ b/src/UI/Inspectors/ReflectionInspector.cs @@ -181,7 +181,7 @@ namespace UnityExplorer.UI.Inspectors timeOfLastAutoUpdate = Time.realtimeSinceStartup; if (AutoUpdateWanted) - UpdateDisplayedMembers();// true); + UpdateDisplayedMembers(); } } @@ -228,7 +228,7 @@ namespace UnityExplorer.UI.Inspectors } } - private void UpdateDisplayedMembers()// bool onlyAutoUpdate) + private void UpdateDisplayedMembers() { bool shouldRefresh = false; foreach (var cell in MemberScrollPool.CellPool) @@ -236,7 +236,7 @@ namespace UnityExplorer.UI.Inspectors if (!cell.Enabled || cell.Occupant == null) continue; var member = cell.MemberOccupant; - if (member.ShouldAutoEvaluate) // && (!onlyAutoUpdate || member.AutoUpdateWanted)) + if (member.ShouldAutoEvaluate) { shouldRefresh = true; member.Evaluate(); @@ -267,10 +267,15 @@ namespace UnityExplorer.UI.Inspectors var member = filteredMembers[index]; - if (cell.Occupant != null && member != cell.Occupant) + if (member.CellView != null && member.CellView != cell) + member.UnlinkFromView(); + + if (cell.Occupant != null && cell.Occupant != member) cell.Occupant.UnlinkFromView(); - member.SetView(cell); + if (member.CellView != cell) + member.SetView(cell); + member.SetDataToCell(cell); SetCellLayout(cell); diff --git a/src/UnityExplorer.csproj b/src/UnityExplorer.csproj index 9958415..3898073 100644 --- a/src/UnityExplorer.csproj +++ b/src/UnityExplorer.csproj @@ -255,7 +255,6 @@ -