using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JsonUtilityManager:BaseManager
{
public JsonUtilityManager(GameManager gameManager) : base(gameManager)
{
}
private Dictionary<UIPanelType, string> panelPathDict;
[Serializable]
class UIPanelTypeJson
{
public List<UIPanelInfo> infoList;
}
private void ParseUIPanelTypeJson()
{
panelPathDict = new Dictionary<UIPanelType, string>();
TextAsset ta = Resources.Load<TextAsset>("Json/UIPanelType");
UIPanelTypeJson jsonObject = JsonUtility.FromJson<UIPanelTypeJson>(ta.text);
foreach (UIPanelInfo info in jsonObject.infoList)
{
panelPathDict.Add(info.panelType, info.path);
}
}
public void Test()
{
string path;
panelPathDict.TryGetValue(UIPanelType.Knapsack, out path);
Debug.Log(path);
panelPathDict.TryGetValue(UIPanelType.ItemMessage, out path);
Debug.Log(path);
panelPathDict.TryGetValue(UIPanelType.MainMenu, out path);
Debug.Log(path);
panelPathDict.TryGetValue(UIPanelType.Shop, out path);
Debug.Log(path);
panelPathDict.TryGetValue(UIPanelType.Skill, out path);
Debug.Log(path);
panelPathDict.TryGetValue(UIPanelType.System, out path);
Debug.Log(path);
panelPathDict.TryGetValue(UIPanelType.Task, out path);
Debug.Log(path);
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-54003.html