AkiraPixelWind/Assets/Scripts/Main/UI/UIMgr/UIMgrPath.cs

62 lines
1.6 KiB
C#
Raw Normal View History

2022-12-29 18:20:40 +08:00
using UnityEngine;
using System;
using System.Collections.Generic;
using UnityEditor;
using Game;
using Axibug.Resources;
using System.IO;
using Game;
public class UIMgrPath : ScriptableObject
{
/// <summary>
/// 所有UI预制体路径
/// </summary>
public List<UIPath> mAllUIPath = new List<UIPath>();
[System.Serializable]
public struct UIPath
{
/// <summary>
/// UI名
/// </summary>
public string mUIName;
/// <summary>
/// UI路径
/// </summary>
public string mUIPath;
}
/// <summary>
/// 同步获取
/// </summary>
/// <param name="_callBack"></param>
public static Dictionary<string, string> GetDic()
{
Dictionary<string, string> retDic = new Dictionary<string, string>();
//string assetsFile = Application.dataPath.Replace("/Assets", "/") + UIMgr.UIPathConfigFile;
//if (!File.Exists(assetsFile))
//{
// Debug.LogError("请先生成UI路径文件. 菜单/UI工具/生成UI预制体路径文件");
// return retDic;
//}
//var xxxFile2Str = File.ReadAllText(assetsFile);
TextAsset ta = (TextAsset)GamePlayEntry.Resources.LoadAsset(UIMgr.UIPathConfigFile);
if(ta == null)
{
Debug.LogError("请先生成UI路径文件. 菜单/UI工具/生成UI预制体路径文件");
return retDic;
}
string xxxFile2Str = ta.text;
retDic = Axibug.LitJson.JsonMapper.ToObject<Dictionary<string, string>>(xxxFile2Str);
//Debug.Log("xxxFile2Str:" + xxxFile2Str);
return retDic;
}
}