IUIAssetModule.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using UnityEngine;
  2. using XGame.Framework.Asset;
  3. namespace XGame.Framework.UI
  4. {
  5. /// <summary>
  6. /// UI的加载模块
  7. /// 每个UIView都有一个独立的IUIAssetModule
  8. /// </summary>
  9. public interface IUIAssetModule
  10. {
  11. /// <summary>
  12. /// 异步加载接口
  13. /// 使用该接口加载的资源严禁使用Object.Destroy销毁,只能使用Recycle(obj)方法回收
  14. /// </summary>
  15. /// <typeparam name="TResult">返回对象类型</typeparam>
  16. /// <param name="addressableName">可寻址资源名字</param>
  17. /// <returns>返回异步回调</returns>
  18. IAssetLoadAsync<TResult> LoadAsync<TResult>(string addressableName) where TResult : Object;
  19. /// <summary>
  20. /// 回收资源
  21. /// </summary>
  22. /// <param name="obj"></param>
  23. /// <param name="isDestroy">是否销毁,只有GameObject可以销毁</param>
  24. void Recycle(Object obj, bool isDestroy = false);
  25. /// <summary>
  26. /// 加载嵌套UI
  27. /// 加载后需要自己设置父节点和激活
  28. /// </summary>
  29. /// <param name="nestedKey">共用UIKey</param>
  30. /// <returns></returns>
  31. IAssetLoadAsync<INestedView> LoadNested(UIKey nestedKey);
  32. /// <summary>
  33. /// 释放INestedView
  34. /// INestedView不复用,只回收GameObject
  35. /// </summary>
  36. /// <param name="nestedView"></param>
  37. /// <param name="isDestroy">是否销毁GameObject, FGUI时忽略该参数</param>
  38. void Recycle(INestedView nestedView, bool isDestroy = false);
  39. /// <summary>
  40. /// 结束所有加载的异步
  41. /// </summary>
  42. void StopAllAsyncs();
  43. ///// <summary>
  44. ///// 释放该UI的所有资源
  45. ///// </summary>
  46. //void UnloadUnusedAssets();
  47. }
  48. public interface IUIAssetModuleCreator
  49. {
  50. /// <summary>
  51. /// 框架业务不要用
  52. /// </summary>
  53. /// <param name="context"></param>
  54. /// <returns></returns>
  55. IUIAssetModule Create(UIContext context);
  56. }
  57. }