I looked at these docs: http://unity3d.com/support/documentation/Manual/Plugins.html But they really skim over it.
Exactly how do I compile an Objective-C function and get it to work in Unity? Is it something I do using Xcode? If so, how do I set up a project in Xcode to do it? When I compile, do I get a compiled file of some sort that I have to add to my Unity Assets?
asked Dec 05 '11 at 06:46 AM
this is how you a call a function declared in xcode
this is the code for the xcode side
Hope this helps....
I have developed game application in unity and give login facility from facebook. i used the http://AppController.mm to login from facebbok and its working fine but i need if user login from facebook and return to the game then game will start automatically, so needed one function to call from AppController to unity for test user is looged or not. it is possible, anyone can help?
@ Gillissie : see there are two ways to create a plugin
1.Write a plugin in c based language compile it and then copy it to the plugin folder in your unity project and then call the methods as per your need
2 call a static extern function in unity,build the project,go to xcode created build,declare and define the function called in unity and do your required in that specific function
i would prefer the 2 ways as i have done enough work on objective c before coming to unity so it helps me there,and i am kinda of confused what you are actually trying to do can you just be a little more precise of what you actually want to create maybe i can suggest you a more easy way out ....
okay so now suppose you want to get the device locale in unity so what you can do here is
write this code in the native function ou created in xcode(awesome function in the code provided above)
This will return a two letter code for the currently selected language. "en" for English, "es" for Spanish, "de" for German, etc. For more examples, please see this Wikipedia entry (in particular, the 639-1 column):
so now you have the locale in the variable which you can return to unity and do whatever changes you want to do based on the locale, you can either return it as a return type or set it in player prefs and read it in unity.
correct me if i took your question wrong.
answered Dec 08 '11 at 07:56 AM