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

52 lines
1.6 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-08 23:11:55 -05:00
public void FindTab(GameElement targetElement, bool findparent = false)
{
if (targetElement.connectedTab != null)
{
targetElement.connectedTab.tabButton.onClick.Invoke();
}
else
{
FindTab(targetElement.parentElement, true);
}
if (findparent && targetElement.connectedTab != null)
{
targetElement.connectedTab.expandButton.onClick.Invoke();
}
}
2025-02-09 23:47:42 -05:00
}
}