Advertisement
Guest User

Untitled

a guest
Feb 5th, 2019
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.AddressableAssets;
  5. using UnityEngine.ResourceManagement;
  6.  
  7. public class LoadingTestScript : MonoBehaviour {
  8.  
  9.     void Start() {
  10.         //Try to load using the Address string:
  11.         Addressables.LoadAssets<TextAsset>("Assets/BlockConfigs/Default.bconfig", null).Completed += onLoadHandler;
  12.         //^^^ Reports back: Null Count: 1     Non-Null Count: 0
  13.         //Try to load using the Label string:
  14.         Addressables.LoadAssets<TextAsset>("BlockConfig", null).Completed += onLoadHandler;
  15.         //^^^ Reports back: Null Count: 1     Non-Null Count: 0
  16.     }
  17.  
  18.     private static void onLoadHandler(UnityEngine.ResourceManagement.IAsyncOperation<IList<TextAsset>> obj) {
  19.         //This is the function that will be called upon load completion.
  20.         List<TextAsset> loadedAssets = new List<TextAsset>();
  21.         loadedAssets.AddRange(obj.Result);
  22.  
  23.         int nullCount = 0; int nonNullCount = 0;
  24.         foreach (TextAsset ta in loadedAssets) {
  25.             if (ta == null) {
  26.                 nullCount++;
  27.             } else {
  28.                 nonNullCount++;
  29.             }
  30.         }
  31.         Debug.Log("Null Count: "+nullCount + "\t Non-Null Count: "+nonNullCount);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement