Unity/Addressable/複数ロード
提供: 初心者エンジニアの簡易メモ
2022年10月10日 (月) 15:57時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「==準備== labelに"TestLabel"を追加 ==サンプル== <pre> using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Addressabl...」)
準備
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); } } } }