using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; using UnityEngine.UI; using UnityExplorer.UI.Widgets.InfiniteScroll; namespace UnityExplorer.UI.Widgets { public class TransformTree : IListDataSource { public Func> GetRootEntriesMethod; public bool Filtering => !string.IsNullOrEmpty(currentFilter); private bool wasFiltering; public string CurrentFilter { get => currentFilter; set { currentFilter = value?.ToLower() ?? ""; if (!wasFiltering && Filtering) wasFiltering = true; else if (wasFiltering && !Filtering) { wasFiltering = false; autoExpandedIDs.Clear(); } } } private string currentFilter; internal InfiniteScrollRect Scroller; internal readonly List displayedObjects = new List(); private readonly Dictionary objectCache = new Dictionary(); private readonly HashSet expandedInstanceIDs = new HashSet(); private readonly HashSet autoExpandedIDs = new HashSet(); public int ItemCount => displayedObjects.Count; public TransformTree(InfiniteScrollRect infiniteScroller) { Scroller = infiniteScroller; } public void Init() { RuntimeProvider.Instance.StartCoroutine(InitCoroutine()); //test var root = new GameObject("StressTest"); for (int i = 0; i < 100; i++) { var obj = new GameObject("GameObject " + i); obj.transform.parent = root.transform; for (int j = 0; j < 100; j++) { new GameObject("Child " + j).transform.parent = obj.transform; } } } private IEnumerator InitCoroutine() { yield return null; RefreshData(); Scroller.DataSource = this; Scroller.Initialize(this); } public ICell CreateCell(RectTransform cellTransform) { var nameButton = cellTransform.Find("NameButton").GetComponent