方块拼图完整版
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace AibisDream.Framework
|
||||
{
|
||||
public static class ResourceKit
|
||||
@@ -72,7 +75,7 @@ namespace AibisDream.Framework
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void LoadAssetAsync<T>(string key, Action<T> callback) where T : UnityEngine.Object
|
||||
{
|
||||
Addressables.LoadAssetAsync<T>(key).Completed += operation =>
|
||||
@@ -87,5 +90,27 @@ namespace AibisDream.Framework
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static bool GetAssetAddressableKey(UnityEngine.Object asset, out string addressableKey)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(asset);
|
||||
// 获取其在Addressables里的路径
|
||||
var settings = UnityEditor.AddressableAssets.AddressableAssetSettingsDefaultObject.Settings;
|
||||
if (settings != null)
|
||||
{
|
||||
var entry = settings.FindAssetEntry(AssetDatabase.AssetPathToGUID(path));
|
||||
if (entry != null)
|
||||
{
|
||||
Debug.Log($"Addressable Key: {entry.address}");
|
||||
addressableKey = entry.address;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Debug.Log($"资源{asset.name}不存在于Addressables中");
|
||||
addressableKey = path;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user