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("default", util => { Debug.Log(util.Data[1].name); }); Debug.Log(Time.time); // TextAsset a = await Addressables.LoadAssetAsync("Assets/StreamingAssetsdata.json"); // Debug.Log($"成功获取到json文件 {Time.time}"); // monsterUtil b = JsonConvert.DeserializeObject(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); } }