本地化

This commit is contained in:
2025-04-25 20:24:11 +08:00
parent 165d154784
commit d69ad072ea
127 changed files with 12788 additions and 1647 deletions
@@ -1,6 +1,9 @@
using System;
using System.Collections;
using UnityEditor;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
namespace AibisDream.Framework
{
@@ -69,5 +72,39 @@ namespace AibisDream.Framework
return null;
}
public static T LoadAddressableSync<T>(string key)
{
T result = default;
var operation = Addressables.LoadAssetAsync<T>(key);
// 运行协程等待加载完成
GameManager.Instance.StartCoroutine(LoadCoroutine(operation, loadedObject => result = loadedObject));
// 等待协程完成(阻塞主线程)
while (!operation.IsDone)
{
// 主动让出一帧
System.Threading.Thread.Sleep(1);
}
return result;
}
public static IEnumerator LoadCoroutine<T>(AsyncOperationHandle<T> operation, Action<T> onComplete)
{
yield return operation;
if (operation.Status == AsyncOperationStatus.Succeeded)
{
onComplete?.Invoke(operation.Result);
}
else
{
Debug.LogError("Failed to load addressable");
}
Addressables.Release(operation);
}
}
}