- Home /
Calling UnitySendMessage requires which library on iOS?
Hi !
I have made a plugin for unity->iOS communication, it worked perfectly and now I'm working on answering from plugin to unity via UnitySendMessage function. I want to build my plugin in a separate project, as it intended to be.
I tried to link two libraries into my plugin found in /Applications/Unity/Unity.app/Contents/PlaybackEngines/iPhonePlayer/iPhone-Trampoline/Libraries/
libiPhone-lib-dev.a
libiPhone-lib.a
The code linked but it crashed the my app.
I need to invoke this function:
Calling C# / JavaScript back from native code Unity iOS supports limited native->managed callback functionality via UnitySendMessage:
UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");
So the question is: -Which headers do I need to include? - Which libraries do I have to link?
Answer by ubik2 · Jun 02, 2012 at 08:23 AM
UnitySendMessage is in libiPhone-lib.a, and as far as I can tell, the Unity folks don't include any header that declares it.
I just added the following to my code
extern void UnitySendMessage(const char *, const char *, const char *);
If you look at the generated AppController.mm, they basically do the same thing for the various UnitySendXXX functions, rather than including a header.
Having said that, while you will be able to build a library that calls UnitySendMessage, that library probably won't work unless it's linked into a Unity project, since UnitySendMessage is going to require more than just libiPhone-lib.a to actually work.
Answer by poncho · Apr 14, 2011 at 01:19 PM
well the SendMessage method is in the GameObject Class wich is in the UnityEngine.dll file i think thats all you need to use hope this helps
I meant message from plugin to unity activated by plugin:
UnitySend$$anonymous$$essage("GameObjectName1", "$$anonymous$$ethodName1", "$$anonymous$$essage to send");
Your answer
Follow this Question
Related Questions
Objective-C and C code in unity plugin 1 Answer
A node in a childnode? 1 Answer
Marshal.PtrToStructure in iPhone makes error. 1 Answer
Is there possible to use Objective-C code inside C unity plugin? 0 Answers
Linking Native toolkit 1 Answer