Files
2026-07-10 10:24:29 +08:00

19 lines
745 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using UnityEngine;
using XWorld.Framework;
namespace XGame.MiniGame
{
// IAssetLoader over XResLoader(异步按需从 CDN 下载/加载小游戏 AB 资源)
public sealed class UnityAssetLoader : IAssetLoader
{
// path: 形如 "Assets/Game/Art/UI/Prefab/UI_RPS.prefab"XResLoader 内部剥 "Assets/" 前缀并按目录解析 AB。
// 用回调版 LoadRes(内部自驱动协程),可在非协程上下文 fire-and-forget;失败回调 null。
public void Load(string path, Action<object> onLoaded)
{
XResLoader.LoadRes(path, typeof(UnityEngine.Object),
objs => onLoaded?.Invoke(objs != null && objs.Length > 0 ? objs[0] : null));
}
}
}