using System; using System.Collections; using System.Collections.Generic; using Ichni.RhythmGame; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; namespace Ichni.Editor { public class Hierarchy : StaticWindow { public GameObject hierarchyTabPrefab; public RectTransform tabContainer; public Button addFolderButton; public List tabList; private void Awake() { tabList = new List(); addFolderButton.onClick.AddListener(() => { ElementFolder.GenerateElement("New Folder", Guid.NewGuid(), new List(), true, null); }); } public HierarchyTab GenerateTab(GameElement targetElement, GameElement parentElement) { HierarchyTab tab = Instantiate(hierarchyTabPrefab, tabContainer).GetComponent(); tab.SetTab(targetElement, parentElement); tabList.Add(tab); return tab; } public ScrollRect scrollRect; public Vector2 vector2; public void FindTab(GameElement targetElement, bool findparent = false) { if (findparent && targetElement.connectedTab != null) { targetElement.connectedTab.expandButton.onClick.Invoke(); } else if (targetElement.connectedTab != null) { targetElement.connectedTab.tabButton.onClick.Invoke(); } else { FindTab(targetElement.parentElement, true); targetElement.connectedTab.tabButton.onClick.Invoke(); } GameElement gameElement = targetElement; HierarchyTab tab = targetElement.connectedTab; while (tab is null) { gameElement = gameElement.parentElement; if (gameElement is null) return; tab = gameElement.connectedTab; } float Tablocalpos = (-tab.transform.localPosition.y) - (tabContainer.sizeDelta.y / 4f); float pct = Tablocalpos / tabContainer.sizeDelta.y; scrollRect.verticalNormalizedPosition = 1f - pct; } } }