I'm working on an animation that pops up a popup screen using DOTween.
private void OnEnable()
{
dialogueBoxTransform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
dialogueBoxTransform.DOScale(new Vector3(1.2f, 1.2f, 1.2f), 0.2f);
dialogueBoxTransform.DOScale(Vector3.one, 0.1f);
}
The problem with the code above is that one of the DOScale() methods is ignored.
So I'm trying to implement it using async-await.
However, when I use Task.Run() it throws an exception because it is not the main thread. So, without using Task.Run(), you should solve it.
To do that, I need to create a method that returns a Task, but I don't know how.
private async void OnEnable()
{
dialogueBoxTransform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
await Test();
dialogueBoxTransform.DOScale(Vector3.one, 0.1f);
}
private Task Test()
{
dialogueBoxTransform.DOScale(new Vector3(1.2f, 1.2f, 1.2f), 0.2f);
return ???
}
I would appreciate any help on what to do.