Where in the execution order does unityInstance.SendMessage get fired from WebGL?
I’ve tried searching throughout the internet and docs but I can’t find the answer to this anywhere. Knowing the answer to this would really help me troubleshoot some issues I’m having.
Are you talking about just regular old SendMessage() for Monobehavior interprocess calls? I thought it fired immediately… this is super-easy to test, just concatenate strings in a particular order and display them in a text field on the WebGL build.
The reference ways these days is to use an interface, and here’s a post I made about it:
Using Interfaces in Unity3D:
If that’s not what you’re talking about, disregard this reply!
I know it’s fired immediately. The reason I’m trying to figure this all out is because the method it calls then calls a few more methods internally that rely on physics updates. Trying to figure out if the SendMessage() is fired “immediately” wherever unity is in the lifecycle (referencing this diagram https://docs.unity3d.com/Manual/ExecutionOrder.html) or if it only gets called before/after one of the items in the diagram.
Depending on that I’ll have to accommodate an extra frame of physics to get the proper values.
I have trouble understanding the distinction here.
If you are in Update() for instance and you call SendMessage, that’s where it happens.
If you’re in OnCollisionEnter() or something else, that’s where it is called.
The best way to deal with timing issues is to deconflict them with some type of a boolean, something that both sides can check and say “Yeah, I guess it’s safe to call you now.”
Seriously recommend switching to interfaces nonetheless. Far better definition of code flow. You explicitly control it all.
SendMessage isn’t something like Update or FixedUpdate which run automagically on a schedule. It runs whenever it is called. That’s why it isn’t in the execution order diagram.