Reputation: 1019
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. This Unity 3D project contains an animation video which I want to play. This project is already build for iOS. What I want is, I first launch my iOS App, then when I click on a button, this Unity 3D animation should play. From the Unity 3D, I should also be able to come back to the iOS App by clicking a Back button or something. 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; a lot of link errors were generated. This link mentions about modifying a class named 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.
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 !
Upvotes: 3
Views: 1808
Reputation: 5951
If you have 2 different applications: Your native app, and the Unity app, you can do the following:
Communicating with Other Apps: 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
Then, to open the app which has registered the custom URL schema you call the following, for instance:
[[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
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. 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.
Upvotes: 1