using XGame.Framework.Asset;

namespace XGame.Framework.UI
{
    /// <summary>
    /// UI的加载模块
    /// 每个UIView都有一个独立的IUIAssetModule
    /// </summary>
    public interface IUIAssetModule
    {
        /// <summary>
        /// 异步加载接口
        /// 使用该接口加载的资源严禁使用Object.Destroy销毁，只能使用Recycle(obj)方法回收
        /// </summary>
        /// <typeparam name="TResult">返回对象类型</typeparam>
        /// <param name="addressableName">可寻址资源名字</param>
        /// <returns>返回异步回调</returns>
        IAssetLoadAsync<TResult> LoadAsync<TResult>(string addressableName) where TResult : UnityEngine.Object;

        /// <summary>
        /// 回收资源
        /// </summary>
        /// <param name="obj"></param>
        void Recycle(UnityEngine.Object obj);
        /// <summary>
        /// 结束所有加载的异步
        /// </summary>
        void StopAllAsyncs();

        ///// <summary>
        ///// 释放该UI的所有资源
        ///// </summary>
        //void UnloadUnusedAssets();
    }
}
