Files
ichni_Creator_Studio/Assets/Scripts/DynamicUI/Hierarchy/Hierarchy.cs

66 lines
2.3 KiB
C#
Raw Normal View History

2025-03-08 23:11:55 -05:00
using System;
2025-02-09 23:47:42 -05:00
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using Unity.VisualScripting;
2025-02-09 23:47:42 -05:00
using UnityEngine;
using UnityEngine.UI;
2025-02-09 23:47:42 -05:00
namespace Ichni.Editor
{
public class Hierarchy : StaticWindow
{
public GameObject hierarchyTabPrefab;
public RectTransform tabContainer;
2025-03-08 23:11:55 -05:00
public Button addFolderButton;
2025-02-09 23:47:42 -05:00
public List<HierarchyTab> tabList;
2025-02-11 22:58:56 -05:00
2025-03-08 23:11:55 -05:00
private void Awake()
{
tabList = new List<HierarchyTab>();
addFolderButton.onClick.AddListener(() =>
{
ElementFolder.GenerateElement("New Folder", Guid.NewGuid(), new List<string>(), true, null);
});
}
2025-02-11 22:58:56 -05:00
public HierarchyTab GenerateTab(GameElement targetElement, GameElement parentElement)
2025-02-09 23:47:42 -05:00
{
2025-02-11 22:58:56 -05:00
HierarchyTab tab = Instantiate(hierarchyTabPrefab, tabContainer).GetComponent<HierarchyTab>();
2025-02-09 23:47:42 -05:00
tab.SetTab(targetElement, parentElement);
tabList.Add(tab);
return tab;
2025-02-09 23:47:42 -05:00
}
2025-03-16 00:42:27 +08:00
2025-05-11 14:12:47 +08:00
public ScrollRect scrollRect;
public Vector2 vector2;
public void FindTab(GameElement targetElement, bool findparent = false)
{
2025-03-16 00:42:27 +08:00
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);
2025-04-13 15:31:33 +08:00
targetElement.connectedTab.tabButton.onClick.Invoke();
}
2025-05-11 14:12:47 +08:00
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;
}
2025-05-11 14:12:47 +08:00
2025-02-09 23:47:42 -05:00
}
}