This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AssetRefLoader | |
{ | |
public static async Task CreateAssetAddToList<T>(AssetReference reference, List<T> completedObjs) | |
where T : Object | |
{ | |
completedObjs.Add(await reference.InstantiateAsync().Task as T); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AssetRefObjectData : MonoBehaviour | |
{ | |
[SerializeField] private AssetReference _sqrARef; | |
[SerializeField] private List<AssetReference> _references = new List<AssetReference>(); | |
private void Start() | |
{ | |
_references.Add(_sqrARef); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task CreateAssetsAddToList<T>(List<AssetReference> references, List<T> completedObjs) | |
where T : Object | |
{ | |
foreach (var reference in references) | |
completedObjs.Add(await reference.InstantiateAsync().Task as T); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SerializeField] private AssetReference _sqrARef; | |
[SerializeField] private List<AssetReference> _references = new List<AssetReference>(); | |
[SerializeField] private List<GameObject> _completedObj = new List<GameObject>(); | |
private void Start() | |
{ | |
_references.Add(_sqrARef); | |
StartCoroutine(LoadAndWaitUntilComplete()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AddressableLocationLoader | |
{ | |
public static async Task GetAll(string label, IList<IResourceLocation> loadedLocations) | |
{ | |
var unloadedLocations = await Addressables.LoadResourceLocationsAsync(label).Task; | |
foreach (var location in unloadedLocations) | |
loadedLocations.Add(location); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoadedAddressableLocations : MonoBehaviour | |
{ | |
[SerializeField] private string _label; | |
public IList<IResourceLocation> AssetLocations { get; } = new List<IResourceLocation>(); | |
private void Start() | |
{ | |
InitAndWaitUntilLoaded(_label); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CreateAddressablesLoader | |
{ | |
public static async Task ByLoadedAddress<T>(IList<IResourceLocation> loadedLocations, List<T> createdObjs) | |
where T : Object | |
{ | |
foreach (var location in loadedLocations) | |
{ | |
var obj = await Addressables.InstantiateAsync(location).Task as T; | |
createdObjs.Add(obj); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CreatedAssets : MonoBehaviour | |
{ | |
private LoadedAddressableLocations _loadedLocations; | |
[field: SerializeField] private List<GameObject> Assets { get; } = new List<GameObject>(); | |
private void Start() | |
{ | |
CreateAndWaitUntilCompleted(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Start() | |
{ | |
CreateAndWaitUntilCompleted("prefab"); | |
} | |
private async Task CreateAndWaitUntilCompleted(string label) | |
{ | |
var locations = await Addressables.LoadResourceLocationsAsync(label).Task; | |
await Addressables.InstantiateAsync(locations[0]).Task; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CreateAddressablesLoader | |
{ | |
public static async Task ByAddress<T>(string label, List<T> createdAssets) where T : Object | |
{ | |
var tempLocations = new List<IResourceLocation>(); | |
await AddressableLocationLoader.GetAll(label, tempLocations); | |
foreach (var location in tempLocations) | |
{ | |
var obj = await Addressables.InstantiateAsync(location).Task as T; |
OlderNewer