This commit is contained in:
2026-06-12 15:22:57 +08:00
parent ad69c6d733
commit 0b64703422
4 changed files with 21 additions and 6 deletions
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 7ba7c6a75110f483683dc4885aee0758
guid: f8c67570025fefa448706dadc37c5988
TextScriptImporter:
externalObjects: {}
userData:
@@ -44,13 +44,14 @@ namespace SGModule.ConfigLoader
public void CopyStreamingAssetsToPersistentDataPath(Action<bool> onComplete = null)
{
Debug.Log("0000000000000000000000000000001");
// 如果目标文件夹不存在,创建它
if (!Directory.Exists(_configFolderPath))
{
Directory.CreateDirectory(_configFolderPath);
}
StartCoroutine(CopyFile(onComplete));
Debug.Log("0000000000000000000000000000002");
CopyFile(onComplete);
}
private void HandleInitializationError()
@@ -68,7 +69,7 @@ namespace SGModule.ConfigLoader
// 比如:显示弹窗或退出程序
}
private IEnumerator CopyFile(Action<bool> onComplete = null)
private void CopyFile(Action<bool> onComplete = null)
{
@@ -80,6 +81,7 @@ namespace SGModule.ConfigLoader
// var jsonFileName = Path.GetFileName(jsonLocation.PrimaryKey);
// 加载 JSON 文件
// var textAssetAsync = Addressables.LoadAssetAsync<TextAsset>(jsonLocation);
Debug.Log("0000000000000000000000000000003");
TextAsset[] files = Resources.LoadAll<TextAsset>("Configs");
// yield return textAssetAsync;
@@ -89,11 +91,10 @@ namespace SGModule.ConfigLoader
string jsonFileName = jsonFile.name;
Log.ConfigLoader.Info($"Loaded JSON Name:{jsonFileName} content: " + jsonFile.text);
Debug.Log("0000000000000000000000000000001");
var destFilePath = Path.Combine(_configFolderPath, jsonFileName);
File.WriteAllBytes(destFilePath, jsonFile.bytes);
onComplete?.Invoke(true);
yield return null;
// }
// else {
// Log.ConfigLoader.Error("Failed to load JSON file");