Beispiel #1
0
 public static UniTask <IEnumerable <TAsset> > LoadAssetsAsync <TAsset>(
     this IAddressablesLoader <TAsset> addressablesLoader,
     IEnumerable <AssetReferenceT <TAsset> > assetReferences)
     where TAsset : Object
 {
     return(addressablesLoader.LoadAssetsAsync(assetReferences.ToArray()));
 }
Beispiel #2
0
 public static T GetComponent <T>(
     this IAddressablesLoader <GameObject> addressablesLoader,
     AssetReferenceComponent <T> assetReference)
     where T : Component
 {
     return(addressablesLoader.GetAsset(assetReference).GetComponent <T>());
 }
Beispiel #3
0
        public static async UniTask <IEnumerable <TAsset> > LoadAssetsAsync <TAsset>(
            this IAddressablesLoader <TAsset> addressablesLoader,
            params AssetReferenceT <TAsset>[] assetReferences)
            where TAsset : Object
        {
            var assetsToLoad = assetReferences
                               .Where(assetReference => addressablesLoader.IsAssetPreloaded(assetReference) == false);

            await addressablesLoader.PreloadAssetsAsync(assetsToLoad);

            return(addressablesLoader.GetAssets(assetReferences));
        }
Beispiel #4
0
        public static bool TryGetAssets <TAsset>(this IAddressablesLoader <TAsset> addressablesLoader,
                                                 out IEnumerable <TAsset> assets, params AssetReferenceT <TAsset>[] assetReferences)
            where TAsset : Object
        {
            if (assetReferences.All(addressablesLoader.IsAssetPreloaded) == false)
            {
                assets = Enumerable.Empty <TAsset>();
                return(false);
            }

            assets = addressablesLoader.GetAssets(assetReferences);
            return(true);
        }
Beispiel #5
0
        public static bool TryGetComponent <T>(
            this IAddressablesLoader <GameObject> addressablesLoader,
            AssetReferenceComponent <T> assetReference, out T component)
            where T : Component
        {
            if (addressablesLoader.TryGetAsset(assetReference, out var gameObject))
            {
                return(gameObject.TryGetComponent(out component));
            }

            component = default;
            return(false);
        }
Beispiel #6
0
        public static async UniTask <TAsset> LoadAssetAsync <TAsset>(
            this IAddressablesLoader <TAsset> addressablesLoader,
            AssetReferenceT <TAsset> assetReference)
            where TAsset : Object
        {
            if (addressablesLoader.IsAssetPreloaded(assetReference))
            {
                return(addressablesLoader.GetAsset(assetReference));
            }

            await addressablesLoader.PreloadAssetAsync(assetReference);

            return(addressablesLoader.GetAsset(assetReference));
        }
Beispiel #7
0
 public static bool TryGetAssets <TAsset>(this IAddressablesLoader <TAsset> addressablesLoader,
                                          IEnumerable <AssetReferenceT <TAsset> > assetReferences, out IEnumerable <TAsset> assets)
     where TAsset : Object
 {
     return(addressablesLoader.TryGetAssets(out assets, assetReferences.ToArray()));
 }
Beispiel #8
0
 public static IEnumerable <TAsset> GetAssets <TAsset>(this IAddressablesLoader <TAsset> addressablesLoader,
                                                       IEnumerable <AssetReferenceT <TAsset> > assetReferences)
     where TAsset : Object
 {
     return(assetReferences.Select(addressablesLoader.GetAsset));
 }
Beispiel #9
0
 public static void UnloadAssets <TAsset>(this IAddressablesLoader <TAsset> addressablesLoader,
                                          params AssetReferenceT <TAsset>[] assetReferences)
     where TAsset : Object
 {
     addressablesLoader.UnloadAssets(assetReferences);
 }
Beispiel #10
0
 public static UniTask PreloadAssetsAsync <TAsset>(this IAddressablesLoader <TAsset> addressablesLoader,
                                                   params AssetReferenceT <TAsset>[] assetReferences)
     where TAsset : Object
 {
     return(addressablesLoader.PreloadAssetsAsync(assetReferences));
 }