54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
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<HierarchyTab> tabList;
|
|
|
|
private void Awake()
|
|
{
|
|
tabList = new List<HierarchyTab>();
|
|
addFolderButton.onClick.AddListener(() =>
|
|
{
|
|
ElementFolder.GenerateElement("New Folder", Guid.NewGuid(), new List<string>(), true, null);
|
|
});
|
|
}
|
|
|
|
public HierarchyTab GenerateTab(GameElement targetElement, GameElement parentElement)
|
|
{
|
|
HierarchyTab tab = Instantiate(hierarchyTabPrefab, tabContainer).GetComponent<HierarchyTab>();
|
|
tab.SetTab(targetElement, parentElement);
|
|
tabList.Add(tab);
|
|
return tab;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
} |