「Unity/Addressable/複数ロード」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==準備== labelに"TestLabel"を追加 ==サンプル== <pre> using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Addressabl...」) |
(相違点なし)
|
2022年10月10日 (月) 15:57時点における版
準備
labelに"TestLabel"を追加
サンプル
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.UI; public class AssetLabelsLoadScene : MonoBehaviour { [SerializeField] Button loadButton; [SerializeField] GameObject canvas; GameObject instance; void Start() { loadButton.onClick.AddListener(() => { if (instance == null) { StartCoroutine(Load()); } }); } IList<GameObject> list; IEnumerator Load() { var handle = Addressables.LoadAssetsAsync<GameObject>("TestLabel", null); yield return handle; if (handle.Status == AsyncOperationStatus.Succeeded) { list = handle.Result; foreach (var value in list) { Debug.Log(value.name); } } } }