Hello everyone,
I am curious about the internals of scripting in Unity.
For my last project, we embedded Lua into C to use as a scripting language. Calling a C function from inside of Lua had a serious performance cost.
What is the performance overhead of calling Unity APIs from inside of a C# script? Is this the sort of thing I should be doing inside of a tight loop?
I see a lot of demos (for example, the Space Shooter project) where the authors attach copies of scripts under objects to give them properties like constant velocity. In a world where interop is expensive, one might instead have a single script that manages newtonian motion for a large collection of objects. This is annoying to do because the logic is typically more complicated.
I was wondering if maybe because Unity is using C# that there is no interop cost at all - maybe my scripts are compiled to native code and directly thunked into the Unity internal code at build time?