如何将 Unity 集成到 Swift 3 iOS 项目中 [英] How to integrate Unity into a Swift 3 iOS project

查看:28
本文介绍了如何将 Unity 集成到 Swift 3 iOS 项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道将 Unity 项目实施到现有 Swift 3 iOS 项目中的最佳策略是什么.到目前为止,我只发现了 Objective-C 中的示例代码.有没有流行的框架或包装器?

I was just wondering what might be the best strategy for implementing a Unity project into a already existing Swift 3 iOS project. So far I only discovered sample code in Objective-C. Is there any popular framework or wrapper out there?

推荐答案

在我看来这个指南非常有帮助:

in my opinion this guide is extremely helpful:

https://github.com/blitzagency/ios-unity5

请注意有一些陷阱:

首先我遇到了几个链接器错误,但我没有考虑到 Unity 项目配置是仅为真实设备"设置的.当我尝试在模拟器上构建项目时,我遇到了 100 多个编译器错误.

First I had several linker errors, but I did not take into account that the Unity project configuration was set up for "real devices" only. When I tried to build the project on the simulator, I had more than 100 compiler errors.

然后我尝试在我的测试设备上构建它,但仍然存在一些错误,直到我注意到我必须添加一些必要的框架,这些框架列在那里:

Then I tried to build it on my test device, but there were still some errors, until I noticed I had to add some of those necessary frameworks, which are listed right there:

https://github.com/blitzagency/ios-unity5/问题/36#issuecomment-303716827

AssetsLibrary、AudioToolbox、AVFoundation、CFNetwork、CoreGraphics、CoreLocation、CoreMedia、CoreMotion、CoreVideo、Foundation、iAd、libiconv.2.tdb、MediaPlayer、MediaToolBox,(这是缺失的)OpenAL、OpenGLES、QuartzCore、安全、系统配置、UIKit、libiPhone-lib.a、libVuforia.a*、libVuforiaUnityPlayer.a*

AssetsLibrary, AudioToolbox, AVFoundation, CFNetwork, CoreGraphics, CoreLocation, CoreMedia, CoreMotion, CoreVideo, Foundation, iAd, libiconv.2.tdb, MediaPlayer, MediaToolBox, (this was the missing one) OpenAL, OpenGLES, QuartzCore, Security, SystemConfiguration, UIKit, libiPhone-lib.a, libVuforia.a*, libVuforiaUnityPlayer.a*

*仅当您在场景中使用 Vuforia 时

*only if you use Vuforia in your scene

最后也是最重要的一步是遵循以下拉取请求中列出的建议,然后它将完美地与 Swift 3 一起运行:

The last and most important step is to follow the advices listed in the following pull request, then it will perfectly run with Swift 3:

https://github.com/blitzagency/ios-unity5/pull/42

合并了其他分支的当前演变(如 swift 3 支持),更新为适用于 Unity 5.5.2、Xcode 8.3.2 和 Swift 3.1,已删除一些像 main.swift 这样的样板增加了暂停统一的可能性充分利用减少的 CPU 周期和电池消耗,当 unity 未运行时(活动)

merged current evolutions from other forks (like swift 3 support), updated to work with Unity 5.5.2, Xcode 8.3.2 and Swift 3.1, removed some boilerplate like main.swift added possibility to pause unity to take full advantage of reduced cpu cylces and therefore battery consumption, when unity is not running (active)

如果你使用 Cocoa Pods,最好不要使用这个 repo 提供的配置文件.我实际上最终手动操作了所有构建设置,因此不会与 pod 配置文件发生冲突.

If you use Cocoa Pods, it's better not to use the config file provided by this repo. I actually ended up manipulating all build settings manually, so there will be no conflicts with the pod config file.

希望能帮到你.

快乐编码

这篇关于如何将 Unity 集成到 Swift 3 iOS 项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆