Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.AddressableAssets;
- using UnityEngine.ResourceManagement;
- public class LoadingTestScript : MonoBehaviour {
- void Start() {
- //Try to load using the Address string:
- Addressables.LoadAssets<TextAsset>("Assets/BlockConfigs/Default.bconfig", null).Completed += onLoadHandler;
- //^^^ Reports back: Null Count: 1 Non-Null Count: 0
- //Try to load using the Label string:
- Addressables.LoadAssets<TextAsset>("BlockConfig", null).Completed += onLoadHandler;
- //^^^ Reports back: Null Count: 1 Non-Null Count: 0
- }
- private static void onLoadHandler(UnityEngine.ResourceManagement.IAsyncOperation<IList<TextAsset>> obj) {
- //This is the function that will be called upon load completion.
- List<TextAsset> loadedAssets = new List<TextAsset>();
- loadedAssets.AddRange(obj.Result);
- int nullCount = 0; int nonNullCount = 0;
- foreach (TextAsset ta in loadedAssets) {
- if (ta == null) {
- nullCount++;
- } else {
- nonNullCount++;
- }
- }
- Debug.Log("Null Count: "+nullCount + "\t Non-Null Count: "+nonNullCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement