简体   繁体   English

在Unity中创建iOS插件

[英]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 我是Unity3d 3.5的新手,我已经阅读了本手册,了解如何在Unity中创建iOS插件(我使用的是专业版): 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. 我的印象是,有一个脚本可以扫描Unity项目文件夹中的Plugins / iOS,并将其中的所有内容符号链接到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? 此外,有人知道在Unity插件/ iOS文件夹中是否有办法让Unity包含.h文件和plist? That sounds like a much easier process. 这听起来像一个简单得多的过程。

And also make sure that you define all your C# methods are of the format : 还要确保您定义的所有C#方法的格式都为:

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

and your c functions should be wrapped inside 并且您的c函数应该包装在里面

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. 我刚刚使用Unity 3.5进行了快速测试,尽管功能有限,但自动将本地代码包含在Assets/Plugins/iOS文件夹中的功能似乎可以使用。 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. 当您使用Unity“ Build”命令创建Xcode项目时,此功能有效,不需要脚本。

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 . 本机代码需要从Assets/Code移至Assets/Plugins/iOS

If you want to copy or modify the info.plist file you can do that using the new [PostProcessBuild] attribute. 如果要复制或修改info.plist文件,则可以使用新的[PostProcessBuild]属性来完成。

http://docs.unity3d.com/Documentation/ScriptReference/PostProcessBuildAttribute.html 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. 您可以使用它来将info.plist从已知位置复制到构建目录,覆盖现有目录,也可以使用PlistCS之类的东西来修改现有info.plist。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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