You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using System.IO;
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using Sirenix.Serialization;
|
|
|
|
using Tools.ExcelResolver;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.AddressableAssets;
|
|
|
|
|
|
|
|
public class Test : MonoBehaviour
|
|
|
|
{
|
|
|
|
private async void Start()
|
|
|
|
{
|
|
|
|
Debug.Log(Time.time);
|
|
|
|
await Addressables.LoadAssetsAsync<monsterUtil>("default", util =>
|
|
|
|
{
|
|
|
|
Debug.Log(util.Data[1].name);
|
|
|
|
});
|
|
|
|
Debug.Log(Time.time);
|
|
|
|
// TextAsset a = await Addressables.LoadAssetAsync<TextAsset>("Assets/StreamingAssetsdata.json");
|
|
|
|
// Debug.Log($"成功获取到json文件 {Time.time}");
|
|
|
|
// monsterUtil b = JsonConvert.DeserializeObject<monsterUtil>(a.text);
|
|
|
|
// Debug.Log($"反序列化成功 {Time.time}");
|
|
|
|
}
|
|
|
|
|
|
|
|
public monsterUtil monsterUtil;
|
|
|
|
string streamingAssetsPath = Application.streamingAssetsPath + "data.json";
|
|
|
|
|
|
|
|
[Button]
|
|
|
|
private void DataToJson()
|
|
|
|
{
|
|
|
|
var settings = new JsonSerializerSettings
|
|
|
|
{
|
|
|
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore // 忽略循环引用
|
|
|
|
};
|
|
|
|
var json = JsonConvert.SerializeObject(monsterUtil, settings);
|
|
|
|
File.WriteAllText(streamingAssetsPath, json);
|
|
|
|
}
|
|
|
|
}
|