using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Threading.Tasks;
using System.Threading;
using UnityEngine.Networking;
using System.Collections;
using UnityEngine.Events;
///
/// 与Editor/GenerateAssetsConfig 配合使用 快速获取资源整路径
///
namespace XFramework
{
public class ResourcesManager
{
static ResourcesManager()
{
//txt>dic
Load();
}
//记录预制件名称以及其对应的预制件路径
static private Dictionary dic = new Dictionary();
static private void Load()
{
//加载配置文件,文本类型
TextAsset textAsset = Resources.
Load("ResMap");
if (textAsset == null)
{
Debug.LogError("未生成ResMap,确定不使用RM功能时可忽略");
return;
}
string mapText = textAsset.text;
//读配置文件 对文本逐行读取
StringReader reader = new StringReader(mapText);
string line = null;
while ((line = reader.ReadLine()) != null)
{
string[] keyValue = line.Split('=');
dic.Add(keyValue[0], keyValue[1]);
}
}
//需要调用的方法 key value
static private string GetValue(string key)
{
if (dic.ContainsKey(key))
{ return dic[key]; }
Debug.LogError($"ResMap中不存在{key}");
return null;
}
////路径》得到对象 【预制件】 path=BaseMeleeAttackSkill
//public static async Task