void Start()
{
Addressables.LoadAssetAsync<GameObject>("Assets/Res/Cube.prefab").Completed += ObjectLoadDone;
}
private void ObjectLoadDone(AsyncOperationHandle<GameObject> obj)
{
if (obj.Status == AsyncOperationStatus.Succeeded)
{
GameObject loadedObject = obj.Result;
Debug.Log("Successfully loaded object.");
instantiatedObject = Instantiate(loadedObject);
Debug.Log("Successfully instantiated object.");
if (accessoryObjectToLoad != null)
{
accessoryObjectToLoad.InstantiateAsync().Completed += op =>
{
if (op.Status == AsyncOperationStatus.Succeeded)
{
instantiatedAccessoryObject = op.Result;
Debug.Log("Successfully loaded and instantiated accessory object.");
}
};
}
}
}
|