123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using UnityEngine;
- namespace XGame.Framework.Asset
- {
- /// <summary>
- /// IAssetModule扩展
- /// </summary>
- public static class AssetModuleExt
- {
- #region 内部扩展方法
- //private static bool IsRegister(this IAssetModule module, object asset, object parent)
- //{
- // if (module == null || asset == null || parent == null)
- // return false;
- // return (module as AssetModule)?.IsRegister(asset.GetLongHashCode(), parent.GetLongHashCode()) ?? false;
- //}
- //private static bool Register(this IAssetModule module, object asset, object parent)
- //{
- // if (module == null || asset == null || parent == null)
- // return false;
- // return (module as AssetModule)?.Register(asset.GetLongHashCode(), parent.GetLongHashCode()) ?? false;
- //}
- //private static bool UnRegister(this IAssetModule module, object asset, object parent)
- //{
- // if (module == null || asset == null || parent == null)
- // return false;
- // return (module as AssetModule)?.UnRegister(asset.GetLongHashCode(), parent.GetLongHashCode()) ?? false;
- //}
- #endregion
- #region GameObject
- ///// <summary>
- ///// 不推荐业务使用同步加载,先屏蔽
- ///// 同步加载 GameObject
- ///// 使用该接口加载的资源严禁使用Object.Destroy销毁,只能使用Recycle(obj)方法回收
- ///// </summary>
- ///// <param name="module"></param>
- ///// <param name="addressableName"></param>
- ///// <returns></returns>
- //public static GameObject LoadSync(this IAssetModule module, string addressableName)
- //{
- // return module.LoadSync<GameObject>(addressableName);
- //}
- /// <summary>
- /// 异步加载 GameObject
- /// 使用该接口加载的资源严禁使用Object.Destroy销毁,只能使用Recycle(obj)方法回收
- /// </summary>
- /// <param name="module"></param>
- /// <param name="addressableName"></param>
- /// <returns></returns>
- public static IAssetLoadAsync<GameObject> LoadAsync(this IAssetModule module, string addressableName)
- {
- return module.LoadAsync<GameObject>(addressableName);
- }
- /// <summary>
- /// 回收GameObject对象接口
- /// </summary>
- /// <param name="module"></param>
- /// <param name="go"></param>
- /// <param name="destroy"></param>
- public static void Recycle(this IAssetModule module, GameObject go, bool destroy)
- {
- if (module == null || go == null) return;
- if (destroy)
- {
- (module as AssetModule)?.Recycle(go, true);
- }
- else
- {
- module.Recycle(go);
- }
- }
- #endregion
- }
- }
|