19 lines
745 B
C#
19 lines
745 B
C#
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));
|
||
}
|
||
}
|
||
}
|