- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
137 lines
4.3 KiB
C#
137 lines
4.3 KiB
C#
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;
|
|
/// <summary>
|
|
/// 与Editor/GenerateAssetsConfig 配合使用 快速获取资源整路径
|
|
/// </summary>
|
|
namespace XFramework
|
|
{
|
|
public class ResourcesManager
|
|
{
|
|
static ResourcesManager()
|
|
{
|
|
//txt>dic
|
|
Load();
|
|
}
|
|
|
|
//记录预制件名称以及其对应的预制件路径
|
|
static private Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
static private void Load()
|
|
{
|
|
//加载配置文件,文本类型
|
|
TextAsset textAsset = Resources.
|
|
Load<TextAsset>("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<Object> Load(string path)
|
|
//{
|
|
// //Skill/BaseMeleeAttackSkill
|
|
// ResourceRequest request = Resources.LoadAsync<Object>(GetValue(path));
|
|
// await request;
|
|
// return request.asset;
|
|
//}
|
|
|
|
public static T Load<T>(string resName) where T :Object
|
|
{
|
|
return Resources.Load<T>(GetValue(resName));
|
|
}
|
|
|
|
//获取资源完整路径
|
|
public static string GetPath(string prefabName)
|
|
{
|
|
return GetValue(prefabName);
|
|
}
|
|
}
|
|
|
|
public class StreamingAssetsManager
|
|
{
|
|
static string streamingAssetaPath; //移动平台待测试
|
|
static StreamingAssetsManager()
|
|
{
|
|
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
|
|
streamingAssetaPath = Application.streamingAssetsPath;
|
|
#elif UNITY_ANDROID || UNITY_IPHONE
|
|
streamingAssetaPath = Application.persistentDataPath;
|
|
#endif
|
|
//txt>dic
|
|
Load();
|
|
}
|
|
|
|
//记录预制件名称以及其对应的预制件路径
|
|
static private Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
//加载本地配置文件
|
|
static private void Load()
|
|
{
|
|
//加载配置文件,文本类型
|
|
|
|
string mapText = File.ReadAllText(streamingAssetaPath + "/SAMap.txt");
|
|
//读配置文件 对文本逐行读取
|
|
StringReader reader = new StringReader(mapText);
|
|
string line = null;
|
|
while ((line = reader.ReadLine()) != null)
|
|
{
|
|
string[] keyValue = line.Split('=');
|
|
dic.Add(keyValue[0], keyValue[1]);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取完整路径
|
|
/// </summary>
|
|
/// <param name="assetsName"></param>
|
|
/// <returns></returns>
|
|
public static string GetPath(string assetsName)
|
|
{
|
|
if (dic.ContainsKey(assetsName))
|
|
{
|
|
return $"{streamingAssetaPath}/{dic[assetsName]}";
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning($"SAMap中不存在{assetsName}");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public IEnumerator Load<T>(string url,UnityAction<T> loaded) where T: Object
|
|
{
|
|
UnityWebRequest webRequest = UnityWebRequest.Get(url);
|
|
yield return webRequest.SendWebRequest();
|
|
if (webRequest.isDone&& webRequest.error == null)
|
|
{
|
|
//loaded.Invoke(webRequest.downloadHandler.)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|