Timeline工具

This commit is contained in:
2026-02-26 15:42:27 +08:00
parent 67b830b50f
commit b6d19e8a8c
6 changed files with 225 additions and 62 deletions
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using UnityEngine;
using UnityEngine.AddressableAssets;
@@ -94,6 +94,31 @@ namespace AibisDream.Framework
};
}
/// <summary>
/// 异步加载 Addressable 资源,callback 接收完整 handle。调用方需在适当时机调用 Release 释放。
/// </summary>
public static void LoadAssetAsyncWithHandle<T>(string key, Action<AsyncOperationHandle<T>> callback) where T : UnityEngine.Object
{
var handle = Addressables.LoadAssetAsync<T>(key);
handle.Completed += operation =>
{
if (operation.Status != AsyncOperationStatus.Succeeded)
{
Debug.Log($"资源{key}不存在");
}
callback(operation);
};
}
/// <summary>
/// 释放 Addressable 加载的 handle
/// </summary>
public static void Release<T>(AsyncOperationHandle<T> handle)
{
if (handle.IsValid())
Addressables.Release(handle);
}
#if UNITY_EDITOR
public static bool GetAssetAddressableKey<T>(T asset, out string addressableKey) where T : UnityEngine.Object
{