Calling Unity from Obj-C (OSX not iOS)

I want to call Unity scripts from Obj-C bundle plugins, so far I’ve spent around 6 hours trying to make it work by including Mono framework to the plugin,
I’ve copied some of the code from tiny tim games blog post http://www.tinytimgames.com/2010/01/10/the-unityobjective-c-divide/
and a number of times I thought that I’ve almost got it, but no matter what I’ve tried I was unable to get a pointer to a MonoDomain (Application Domain) that is being used by Unity in the same time in order to call it’s scripts.

If anyone has any idea other than exchanging calls to Unity with monitoring from inside Unity then it would make me a very happy man and I’d owe that gentleman a beer…

Thank you...it worked

–

1 Answer

1

Communication plugin → unity is normally either done through the function result you send back or at worst through a callback to a nonUnityEngine object.

Depending on what you do either of the two is the way to go, guess you will go with callbacks - delegates to a function on a non UnityEngine object that then forwards the information to a queue, list<> or something alike on a unity engine object to use.

The callback can also be to a UnityEngine object BUT only if your plugin does not use an own thread and is not running asyncronous at the point you call the callback (>unity is not threadsafe and such a call will pretty surely make the whole application crash)