SendMesssage: object <NAME> not found!

Hey folks,

I’m having some problems with the web player occasionally crashing while my project is running.

I’m looking at Player.log to see if I can resolve any problems that might show up there. I see some messages of the form:

“SendMessage: object not found!”

My JS calls SendMessage to pass information back and forth from the Unity Web Player to the rest of the page. I’m guessing these messages appear when I destroy objects.

Is there any way to extend the Unity SendMessage function so that I can test to make sure the object exists (so that I don’t try to call non-existent functions or objects)?

Alternatively, is there some sort of error checking I can do in the JavaScript so that I can test for the existence of the object before calling SendMessage on it?

I see that SendMessage has “SendMessageOptions” but this looks like it applies to SendMessage in Unity itself (not SendMessage calls to Unity by the JS).

Thanks,
Jared

No, you have to use the function as-is and it requires the named object to exist, else you get this behavior.

If you’re worried about having non-existent objects then I would suggest creating an always-present message dispatching object, you send it all SendMessage calls (never destroy it!), it can then parse the provided message which should include information about the actual intended recipient. Then your dispatcher will receive all SendMessage calls and can then look for the named object and if present send it the message, and if not simply eat the data and prevent any errors or issues.