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

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

问题描述

我只是想知道在已经存在的Swift 3 iOS项目中实施Unity项目的最佳策略。到目前为止,我只在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/issues/36#issuecomment-303716827


AssetsLibrary,AudioToolbox,AVFoundation,CFNetwork,CoreGraphics,
CoreLocation,CoreMedia,CoreMotion,CoreVideo,Foundation,iAd,
libiconv.2。 tdb,MediaPlayer,MediaToolBox,(这是缺少的)
OpenAL,OpenGLES,QuartzCore,Security,SystemConfiguration,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

最后也是最重要的小号tep将遵循以下pull请求中列出的建议,然后它将与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 cylces,因此当unun不运行时,电池
消耗(活动)

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.

我希望我能帮助你一点点。

I hope I could help you a little bit.

快乐编码

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

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