简体   繁体   中英

Creating iOS Plugin in Unity

I'm very new to Unity3d 3.5, and I've been reading over this manual for how to create iOS plugins in Unity (I'm using the pro version): http://unity3d.com/support/documentation/Manual/PluginsForIOS.html

I'm under the impression that there is a script that will scan Plugins/iOS in Unity's project folder, and symlink everything in there into Xcode. The manual pretty much just scims over how to do it, and it is not very helpful for a beginner. I was wondering if there is just a single file floating around that will accomplish this, or if it is different for every app? Any help is much appreciated, thanks in advance!

Also, does anyone know if there is a way to have Unity include the .h files and plist's in the Plugins/iOS folder? That sounds like a much easier process.

And also make sure that you define all your C# methods are of the format :

[DllImport ("__Internal")] private static extern float FooPluginFunction ();

and your c functions should be wrapped inside

extern "C" {
  float FooPluginFunction ();
 } 

If they are not, your app will break

I just tried a quick test with Unity 3.5 and the feature to automatically include the native code in the Assets/Plugins/iOS folder appears to work, although it is limited. As the document mentions, subfolders are not supported. This feature works when you create your Xcode project by using the Unity "Build" command, no script is required.

There is a sample project linked to on that page, but it is not set up properly. The native code needs to be moved from Assets/Code to Assets/Plugins/iOS .

If you want to copy or modify the info.plist file you can do that using the new [PostProcessBuild] attribute.

http://docs.unity3d.com/Documentation/ScriptReference/PostProcessBuildAttribute.html

You can use that to copy an info.plist from a known location to your build directory, overwriting the existing one, or you can use something like PlistCS to modify the existing info.plist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM