贺州人民医院电子沙盘
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

56 lines
1.8 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResourceLoadPanel<T> : MonoBehaviour where T : ResourceLoadPanel<T>
{
private static T instance;
public static T GetInstance
{
get
{
if (instance == null)
{
string path = "UI/" + typeof(T);
GameObject obj = Resources.Load<GameObject>(path);
if(!GameObject.Find("Canvas").transform)
{
return null;
}
GameObject clone = Instantiate(obj, GameObject.Find("Canvas").transform);
clone.transform.SetAsLastSibling();
clone.name = typeof(T).ToString();
//clone.transform.position = Vector3.zero;
instance = clone.GetComponent<T>();
if (!clone.GetComponent<HideUIWhileClear>())
{
clone.AddComponent<HideUIWhileClear>();
}
}
//if (!instance.gameObject.activeSelf)
// instance.gameObject.SetActive(true);
return instance;
}
}
public static T GetActiveInstance
{
get
{
if (instance == null)
{
string path = "UI/" + typeof(T);
GameObject obj = Resources.Load<GameObject>(path);
GameObject clone = Instantiate(obj, GameObject.Find("Canvas").transform);
clone.transform.SetAsLastSibling();
clone.name = typeof(T).ToString();
//clone.transform.position = Vector3.zero;
instance = clone.GetComponent<T>();
}
if (!instance.gameObject.activeSelf)
instance.gameObject.SetActive(true);
return instance;
}
}
}