I am fiddling around with the sculpt sphere example in the procedural generation examples. This is real cool example, except it has one fatal flaw and that is, when you stop sculpting and let go of the mouse button, it calls a function that is processor intensive enough that it makes the movement of the camera pause for a second.
I’m wondering, would it be possible in anyway to have unity call this processor intensive function in the background, so then the rest of unity could still be taking user input in at full speed and have it not pause?
I haven’t looked at the code in question, but my guess is that the object being sculpted has a MeshCollider. Updating MeshColliders is very expensive, but unfortunately necessary if you want subsequent clicks to fall on the new shape instead of the original sphere. There is no way to make this update asynchronous.
Updating mesh data (especialy on low end gpus) and rebuilding the whole collision tree are intense and will always remain intense unless there is some magic discovered to do it in no time (but otherwise, you will just have to keep in mind that spatial tree generation takes its time to save you a lot of time afterwards)
You can run the mesh recalculation in another thread, so it runs parallel to the rest of the game and doesn’t cause any hiccups. Yes, I have done this, and it’s quite nice. The catch? It’s not thread-safe, so it will crash half the time.
So, if they eventually make this thread-safe, then you will be able to do it. But you still have intensive processing going on, whether it’s in the background or not, so you’d have to wait until it was done before you’d allow user input again (as far as sculpting the sphere goes anyway).