IAssetModule.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. 
  2. using XGame.Framework.Asyncs;
  3. namespace XGame.Framework.Asset
  4. {
  5. /// <summary>
  6. /// 资源模块接口
  7. /// </summary>
  8. public interface IAssetModule
  9. {
  10. /// <summary>
  11. /// 转换AddressableName
  12. /// 会根据游戏当前语言、品质等级返回对应的AddressableName
  13. /// </summary>
  14. /// <param name="addressableName"></param>
  15. /// <returns></returns>
  16. string ConvertAddressableName(string addressableName);
  17. ///// <summary>
  18. ///// 同步加载接口
  19. ///// 使用该接口加载的资源严禁使用Object.Destroy销毁,只能使用Recycle(obj)方法回收
  20. ///// </summary>
  21. ///// <typeparam name="TResult">返回值类型</typeparam>
  22. ///// <param name="addressableName">可寻址资源名字</param>
  23. ///// <returns>返回泛型对象</returns>
  24. //TResult LoadSync<TResult>(string addressableName);
  25. ///// <param name="assetTag">资源标签,默认为空,相同标签的的异步加载可使用标签统一删除或结束回调</param>
  26. /// <summary>
  27. /// 异步加载接口
  28. /// 使用该接口加载的资源严禁使用Object.Destroy销毁,只能使用Recycle(obj)方法回收
  29. /// </summary>
  30. /// <typeparam name="TResult">返回对象类型</typeparam>
  31. /// <param name="addressableName">可寻址资源名字</param>
  32. /// <returns>返回异步回调</returns>
  33. IAssetLoadAsync<TResult> LoadAsync<TResult>(string addressableName);
  34. /// <summary>
  35. /// 回收资源
  36. /// </summary>
  37. /// <param name="obj"></param>
  38. void Recycle(object obj);
  39. ///// <summary>
  40. ///// 停止指定的异步加载
  41. ///// </summary>
  42. ///// <typeparam name="TResult"></typeparam>
  43. ///// <param name="async"></param>
  44. //void StopAsync<TResult>(IAssetLoadAsync<TResult> async);
  45. /// <summary>
  46. /// 结束所有加载的异步
  47. /// </summary>
  48. void StopAllAsyncs();
  49. /// <summary>
  50. /// 卸载所有没有使用的资源
  51. /// </summary>
  52. void UnloadUnusedAssets();
  53. ///// <summary>
  54. ///// 预留 Instantiate UnityEngine.Object
  55. ///// </summary>
  56. ///// <typeparam name="TObject"></typeparam>
  57. ///// <param name="original"></param>
  58. ///// <returns></returns>
  59. //TObject Instantiate<TObject>(TObject original) where TObject : UnityEngine.Object;
  60. /// <summary>
  61. /// 异步加载Scene的AssetBundle到内存
  62. /// </summary>
  63. /// <param name="sceneName"></param>
  64. IAsync LoadSceneBundleAsync(string sceneName);
  65. /// <summary>
  66. /// 卸载scene的AssetBundle
  67. /// </summary>
  68. /// <param name="sceneName"></param>
  69. void UnLoadSceneBundle(string sceneName);
  70. #region 预加载
  71. /// <summary>
  72. /// 预加载接口
  73. /// 只加载不实例化
  74. /// </summary>
  75. /// <typeparam name="TResult"></typeparam>
  76. /// <param name="addressableName"></param>
  77. /// <returns></returns>
  78. IAssetPreloadAsync PreloadAsync<TResult>(string addressableName);
  79. /// <summary>
  80. /// 释放预加载的资源
  81. /// 如果预加载的资源已经实例化,则无效
  82. /// </summary>
  83. /// <param name="addressableName"></param>
  84. void UnloadPreloadAsset(string addressableName);
  85. #endregion
  86. }
  87. }