AssetLoadHandler.cs 725 B

12345678910111213141516171819202122
  1. using XGame.Framework.Asset;
  2. namespace XGame.Editor.Asset
  3. {
  4. public class AssetLoadHandler : IAssetLoadHandler
  5. {
  6. TResult IAssetLoadHandler.LoadSync<TResult>(string addressableName)
  7. {
  8. var type = typeof(TResult);
  9. if (type.IsSubclassOf(typeof(UnityEngine.Object)))
  10. {
  11. var assetPath = AddressableHelper.NameToAssetPath(addressableName);
  12. if (string.IsNullOrEmpty(assetPath) == false)
  13. {
  14. var result = UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath, type) as object;
  15. return (TResult)result;
  16. }
  17. }
  18. return default(TResult);
  19. }
  20. }
  21. }