using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResourcesManager {
private static ResourcesManager _Instance = null;
public static ResourcesManager Instance
{
get
{
if (_Instance == null)
{
_Instance = new ResourcesManager();
}
return _Instance;
}
}
private string jsonPath = "Config";
public TextAsset GetJsonText(string name)
{
return LoadJsonAsset(jsonPath,name);
}
public TextAsset LoadJsonAsset(string path,string name)
{
TextAsset textAsset = null;
string loadPath=path+"/"+name;
textAsset = Resources.Load(loadPath,typeof(TextAsset))as TextAsset;
if (textAsset == null)
{
Debug.Log("加载路径出错:" + loadPath);
return null;
}
return textAsset;
}
private string uiPrefabPath = "UI/Panel";
public GameObject GetUIPrefab(string name)
{
return LoadPrefab(name, uiPrefabPath);
}
public GameObject LoadPrefab(string name, string path)
{
string loadPath = path + "/" + name;
GameObject prefab = Resources.Load(loadPath, typeof(GameObject)) as GameObject;
if (prefab == null)
{
Debug.LogError("prefab is not exist:" + loadPath);
}
return prefab;
}
}
ResourcesManager
最新推荐文章于 2024-03-06 23:31:25 发布