|
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? Thanks.
(comments are locked)
|
|
this is how you a call a function declared in xcode this is the code for the xcode side AppController.h AppController.mm Hope this helps.... Yes, thanks, that does help. But it doesn't tell me how to compile it and what files are a result of the compile, and what I do with said file(s) after compiling. Would I put the file in the Unity project's Assets folder somewhere?
Dec 08 '11 at 06:34 AM
Gillissie
you dont have to put the files in unity asset folder... lets go by an example suppose you have to add inapp plugin to ur game... 1.Copy the sdk provided for the inapp in your xcode project. 2. now you can call the method required for the inapp(from the sdk) in the method awesome function as declared above. 3. now when the inapp is successful you can send a confirmation back to unity by changing the value set for playerpref as i shown in the code above or there are many other ways to do it i am just suggesting how i would do that. now if you ask how to use the sdk methods in xcode then you have to go to stackoverflow and search there ...
Dec 08 '11 at 06:42 AM
crazyKnight
Thanks, but I don't want to call someone else's sdk. I just want to know how to create an xcode plugin project from scratch like your example above, then compile it, and any other steps required to make it so I can make calls to it from Unity. I understand how to make calls to it, but I don't know how to set up the plugin project and compile it.
Dec 08 '11 at 07:26 AM
Gillissie
Maybe I'm misunderstanding how it works overall. Maybe I don't compile the plugin? Maybe it is added to the xcode project that is generated by Unity when I build?
Dec 08 '11 at 07:28 AM
Gillissie
The docs are confusing (go figure). At the top it says this: "In order to use a plugin you need to do two things: Write a plugin in a C based language and compile it. Create a C# script which calls functions in the plugin to do something." Then it goes on to say this: "Add your native implementation to the generated XCode project's "Classes" folder (this folder is not overwritten when project is updated, but don't forget to backup your native code)." So based on the first statement, I expected to compile a plugin by itself, not as part of the generated project. But the second statement says to put it in the generated project.
Dec 08 '11 at 07:32 AM
Gillissie
(comments are locked)
|
|
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? Thanks
(comments are locked)
|
|
@ 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 .... sorry that should have been a comment...
Dec 08 '11 at 07:43 AM
crazyKnight
I want to get access to native iOS properties, such as locale, and maybe sqlite3 database support for saving games. I want to do things that you can do on an iPhone but not natively in Unity.
Dec 08 '11 at 07:47 AM
Gillissie
(comments are locked)
|
|
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): http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 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. I appreciate your help, but this isn't answering my question. However, I think I may be able to figure it out based on bits and pieces that I can gather from this whole conversation. The question isn't how to get the locale (that was just one example of what I want to do with plugins), the question is how to get it working. I think the answer lies in the fact that there are two different kinds of plugins.
From what I gather, what I want is #2.
Dec 08 '11 at 08:23 AM
Gillissie
Thanks for your help. I have it figured out now. The Bonjour example project helped me too.
Dec 08 '11 at 09:28 AM
Gillissie
(comments are locked)
|

Really, no answers? Nobody is doing this?
which plugin do u want to add..????
I want to write and compile my own plugins so I can use native iOS functionality from within Unity's scripts. I think that's what plugins are for, if I'm not mistaken.