I have encountered two separate problems that have suggested this. In both cases I called function to set a variable that was then used for something else on the next line. Unity would then throw an error saying that the variable that’s value is set by a function has an invalid value. It doesn’t make any sense why it would do it that way, but it is the only explanation as problems were both solved by moving that line inside the function.
No, there is no threading in Unity scripting. There are a few async functions, clearly noted in the docs, but even those aren’t actually separate threads. Probably worth reading about execution order though. (It’s possible to do threads, but it must be done manually using System.Threading, and can’t involve the Unity API.)
–Eric
2 Likes
Code example? There is a 99.9% chance this is simply user error.