You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
656 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using HGR.Core.Singletons;
using UnityEngine;
public class UI_Manager : Singleton<UI_Manager>
{
[SerializeField]
private List<TWS_UIPanel> _panels;
[SerializeField]
private Transform UI_Panels_Parent;
TWS_UIPanel spawnedPanel;
public TWS_UIPanel OpenPanel<T>() where T : TWS_UIPanel
{
if (spawnedPanel != null)
Destroy(spawnedPanel.gameObject);
TWS_UIPanel foundPanel = _panels.Find(x=> x.GetType() == typeof(T));
spawnedPanel = Instantiate(foundPanel, UI_Panels_Parent);
return spawnedPanel;
}
}