Unity3D: Direct Function calling vs SendMessage

Comparing calling a function directly in a script vs using SendMessage to a Game Object.

Two counters start simultaneously, counting to 1,000 and sending the int ‘1’ to a function in another script.

SendMessage uses:

Direct Function uses:

SendMessage takes just over twice as long to perform the same feat as Direct Function (209%).


SendMessage has an advantage in that you don’t need to know the name of the script on the GameObject you’re sending the message to. Direct Function needs to know the name of the script.

Aside from being faster, Direct Function can also send more than one parameter to a function in another script, so you could send a string, float, int, Vector2, Vector3 and more in one single code, provide the function you’re sending them to can receive those parameters.


crScript.countem(13.509Quote thisVector2(1.0,2.0), Vector3(2.5,3.5,4.5));


You can find the example project from the video above here: SendMessage vs Direct Function