| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using GFGGame;
- using SimpleJSON;
- using UnityEngine;
- using YooAsset;
- public class CommonDataManager2 : Singleton<CommonDataManager2>
- {
- public static cfg.Tables Tables;
- protected override void Awake()
- {
- base.Awake();
- DontDestroyOnLoad(gameObject);
- }
- public void Init()
- {
- Tables = new cfg.Tables(LoadByteBuf);
- }
- private JSONNode LoadByteBuf(string file)
- {
- var str = ReadStringSync(file);
- if (string.IsNullOrEmpty(str))
- {
- Debug.LogError("load luban json failed:" + file);
- return null;
- }
- return JSON.Parse(str);
- }
- public string ReadStringSync(string loc)
- {
- var handler = YooAssets.LoadAssetSync<Sprite>(loc);
- if (handler == null)
- {
- return null;
- }
- var data = handler.AssetObject as TextAsset;
- return data != null ? data.text : null;
- }
- }
|