My question is in the code below, I try different methods to load the object from the Addressable, I tried referencing the object using drag and drop and only by code, which is the Loadasset and give a key to it.
My question is the Key aMMox/AmooBox.FBX is only recognised by the Addressable.LoadAsset method. But if the object is downloaded it should be stored somewhere, maybe is the location where I stored it in the asset folder in the first place? If that's true can't I just get the object by the path after confirming it's been downloaded? Because if I have many game objects, keeping LoadAsset and giving it a key seems a dumb way to do it
[SerializeField] private AssetReference playerArmatureAssetReference;
[SerializeField] private AssetRefereceAudioClip musicAssetReference;
[SerializeField] private AssetReferenceTexture2D unityLogoAsset;
private void Start()
{
Addressables.LoadAsset<GameObject>("aMMOox/AmmoBox.FBX").Completed += onLoadDone;
Addressables.InitializeAsync().Completed += Addressables_Completed;
}
void Addressables_Completed(AsyncOperationHandle<IResourceLocator> obj)
{
musicAssetReference.LoadAssetAsync<AudioClip>().Completed += (clip) =>
{
Debug.Log("Working");
var audioSource = gameObject.AddComponent<AudioSource>();
audioSource.clip = clip.Result;
audioSource.playOnAwake = false;
audioSource.loop = true;
audioSource.Play();
};
playerArmatureAssetReference.LoadAssetAsync<GameObject>().Completed += (gameobj) =>
{
Debug.Log("CloudGameObj");
var Zombie = gameobj.Result;
Instantiate(Zombie, new Vector3(0.031f, -0.023f, 0.128f), Quaternion.identity);
};
}
private void onLoadDone(AsyncOperationHandle<GameObject> obj)
{
var test = obj.Result;
Instantiate(test, new Vector3(0.031f, -0.023f, 0.128f), Quaternion.identity);
Debug.Log(test.name);
}
}