简体   繁体   English

如何从本机iOS应用程序启动Unity 3D App

[英]How to launch Unity 3D App from a native iOS App

I have an iOS project with me which was developed in Xcode 5. I also have a Unity 3D project developed in 4.3 free version. 我有一个iOS项目,我在Xcode 5中开发。我还有一个4.3免费版开发的Unity 3D项目。 This Unity 3D project contains an animation video which I want to play. 这个Unity 3D项目包含一个我想要播放的动画视频。 This project is already build for iOS. 该项目已经为iOS构建。 What I want is, I first launch my iOS App, then when I click on a button, this Unity 3D animation should play. 我想要的是,我首先启动我的iOS应用程序,然后当我点击一个按钮时,这个Unity 3D动画应该播放。 From the Unity 3D, I should also be able to come back to the iOS App by clicking a Back button or something. 在Unity 3D中,我还应该能够通过单击“后退”按钮或其他内容返回到iOS应用程序。 To achieve this, I tried out the steps mentioned in the link below - http://alexanderwong.me/post/29949258838/building-a-ios-unity-uiview-uiviewcontroller - but it didn't help; 为实现这一目标,我尝试了以下链接中提到的步骤 - http://alexanderwong.me/post/29949258838/building-a-ios-unity-uiview-uiviewcontroller - 但它没有帮助; a lot of link errors were generated. 生成了很多链接错误。 This link mentions about modifying a class named AppController. 此链接提到有关修改名为AppController的类。 I didn't find such a class in my Unity 3D project, instead I saw a class named UnityAppController instead, hence I modified that. 我没有在Unity 3D项目中找到这样的类,而是看到了一个名为UnityAppController的类,因此我对其进行了修改。

Could someone guide me regarding how I can accomplish the above mentioned task. 有人可以指导我如何完成上述任务。 If any of you guys can provide me with some sample code that works, then it would be of great help. 如果你们中的任何人能够提供一些有用的示例代码,那么它将会有很大的帮助。 Thanks in advance ! 提前致谢 !

If you have 2 different applications: Your native app, and the Unity app, you can do the following: 如果您有2个不同的应用程序:您的本机应用程序和Unity应用程序,您可以执行以下操作:

Communicating with Other Apps: https://developer.apple.com/library/IOs/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW18 与其他应用程序通信: https//developer.apple.com/library/IOs/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW18

And you'll have to register a custom URL schema for the app, you want to open: https://developer.apple.com/library/IOs/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW50 您必须为应用注册自定义URL架构,并且要打开: https//developer.apple.com/library/IOs/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#// apple_ref / DOC / UID / TP40007072-CH7-SW50

Then, to open the app which has registered the custom URL schema you call the following, for instance: 然后,要打开已注册自定义URL架构的应用程序,请调用以下内容,例如:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mycustomurlschema://app"]];

To call this from your Unity app when you want to switch back to your native app, you have to follow these instructions in order to execute native code: Building Plugins for iOS: https://docs.unity3d.com/Documentation/Manual/PluginsForIOS.html 要在切换回本机应用程序时从Unity应用程序调用此项,您必须按照以下说明执行本机代码: 为iOS构建插件: https //docs.unity3d.com/Documentation/Manual/ PluginsForIOS.html

If you want to, however, combine your native app and your Unity app into one single app please tell me if you find out how to do this. 但是,如果您希望将原生应用程序和Unity应用程序合并到一个应用程序中,请告诉我您是否知道如何执行此操作。 I searched the internet for a good solution, but the only solutions I could find were projects where Unity is permanently running in the background and draw some native views over the Unity-view which seems to be not a very good solution and quite cumbersome. 我在互联网上搜索了一个很好的解决方案,但我能找到的唯一解决方案是Unity在后台永久运行的项目,并在Unity视图上绘制一些原生视图,这似乎不是一个非常好的解决方案,而且非常繁琐。

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

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