Hi everyone,
I have an expensive function that takes 3-4 seconds to complete. When I call this function inside of a script it, app freezes for 3-4 seconds till the result back. I have searched and seen async/await/task method. It says it is like javascript async/await but I coudn’t make it work. Like in javascript can I make my expensive function async so that it works in the background without freezing my unity app? How can I make function async and wait result in coroutine yield return or await?
public void ExpensiveFunction()
{
// Lots of operations.
}
IEnumerator MyCoroutine()
{
await MyResult = ExpensiveFunction();
}