打开窗口框架

This commit is contained in:
2025-07-16 19:16:46 +08:00
parent a6f442044a
commit 5348216024
10 changed files with 125 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
@@ -9,11 +10,16 @@ namespace CreatGame.AssetBundle
{
public class AssetBundleManager : Singleton<AssetBundleManager>
{
/// <summary>
/// 是否初始化完成
/// </summary>
public bool IsInitializeAsync;
/// <summary>
/// 需要初始化Addressble系统
/// </summary>
public AssetBundleManager()
{
IsInitializeAsync = false;
Addressables.InitializeAsync();
}
@@ -54,7 +60,26 @@ namespace CreatGame.AssetBundle
// }
// }
#endregion
IsInitializeAsync = true;
}
}
public void LoadGameObject(string assetBundleName, Action<GameObject> callback)
{
Addressables.LoadAssetAsync<GameObject>(assetBundleName).Completed += (handle) =>
{
if (handle.Status == AsyncOperationStatus.Succeeded)
{
var asset = handle.Result;
callback?.Invoke(GameObject.Instantiate(asset));
}
else
{
Debug.Log($"assetBundleName = {assetBundleName} 加载失败 Status = {handle.Status}");
callback?.Invoke(null);
}
};
}
}
}