mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
Fix cell view link mismatch
This commit is contained in:
parent
6c7acf7690
commit
9e8a18a5e1
@ -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();
|
||||
|
@ -65,7 +65,6 @@ namespace UnityExplorer.UI.CacheObject
|
||||
|
||||
protected const string NOT_YET_EVAL = "<color=grey>Not yet evaluated</color>";
|
||||
|
||||
|
||||
public virtual void ReleasePooledObjects()
|
||||
{
|
||||
if (this.IValue != null)
|
||||
@ -97,6 +96,9 @@ namespace UnityExplorer.UI.CacheObject
|
||||
|
||||
public void SetUserValue(object value)
|
||||
{
|
||||
if (State == ValueState.String)
|
||||
ReflectionProvider.Instance.BoxStringToType(ref value, FallbackType);
|
||||
else
|
||||
value = value.TryCast(FallbackType);
|
||||
TrySetUserValue(value);
|
||||
}
|
||||
|
@ -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<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
//var content = UIFactory.CreateUIObject("Content", UIRoot);
|
||||
//UIFactory.SetLayoutGroup<VerticalLayoutGroup>(content, true, false, true, true, 2, 0);
|
||||
//UIFactory.SetLayoutElement(content, minWidth: 100, flexibleWidth: 9999, minHeight: 30, flexibleHeight: 600);
|
||||
//content.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
var horiRow = UIFactory.CreateUIObject("HoriGroup", UIRoot);
|
||||
UIFactory.SetLayoutElement(horiRow, minHeight: 29, flexibleHeight: 150, flexibleWidth: 9999);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(horiRow, false, false, true, true, 5, 2, childAlignment: TextAnchor.UpperLeft);
|
||||
|
@ -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();
|
||||
|
||||
if (entry.CellView != cell)
|
||||
entry.SetView(cell);
|
||||
|
||||
entry.SetDataToCell(cell);
|
||||
|
||||
SetCellLayout(cell);
|
||||
|
@ -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();
|
||||
|
||||
if (entry.CellView != cell)
|
||||
entry.SetView(cell);
|
||||
|
||||
entry.SetDataToCell(cell);
|
||||
}
|
||||
|
||||
|
@ -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<CacheListEntryCell>, 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<object> values = new List<object>();
|
||||
// private readonly List<CacheListEntry> cachedEntries = new List<CacheListEntry>();
|
||||
|
||||
// public ScrollPool<CacheListEntryCell> 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<CacheListEntryCell>(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<LayoutElement>();
|
||||
|
||||
// return UIRoot;
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -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();
|
||||
|
||||
if (member.CellView != cell)
|
||||
member.SetView(cell);
|
||||
|
||||
member.SetDataToCell(cell);
|
||||
|
||||
SetCellLayout(cell);
|
||||
|
@ -255,7 +255,6 @@
|
||||
<Compile Include="UI\IValues\InteractiveDictionary.cs" />
|
||||
<Compile Include="UI\IValues\InteractiveList.cs" />
|
||||
<Compile Include="UI\IValues\InteractiveValue.cs" />
|
||||
<Compile Include="UI\Inspectors\ListInspector.cs" />
|
||||
<Compile Include="UI\Inspectors\ReflectionInspector.cs" />
|
||||
<Compile Include="UI\ObjectPool\IPooledObject.cs" />
|
||||
<Compile Include="UI\ObjectPool\Pool.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user