- Home /
URL scheme to launch Unity3d app in iOS
Hi everyone.
I've made a Unity3d iOS app which has two modes internally: Mode A and Mode B, which do different things within the app. There's gonna be another iOS app (non Unity3d) which can launch my app in either mode via the iOS URL scheme. For example: to launch my app in mode A, the URL to be called will be something like project:\\\modeA and project:\\\modeB to launch mode B.
Now I know that the UIApplication delegate in Unity3D is the AppController.mm file which is created once we've built the project.
My question is: how do I pass these URL parameters to the Unity app which determine the mode to be opened under ? And how should a Unity script do the polling to find out about the parameters and start the app in a particular mode ?
Any help in this regard is appreciated.
Answer by liszto · Oct 29, 2012 at 10:37 PM
I think what you search is here : http://docs.unity3d.com/Documentation/Manual/PluginsForIOS.html
You must probably use the Unity/XCode call back.
So to do that you probably gonna use : UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");
I don't know if it's exactly what you need but I think It's a good start ;). I'm still searching..
Answer by vprabhu · Oct 30, 2012 at 02:41 AM
You are right. I need to create a plugin that's coded in Objective C which passes parameters via the URL method to the Unity3d app. Using those parameters I could enable the different modes within the game. Also, I'm guessing this plugin would need to be added to the libraries in the xcode project.
Indeed you must add it to XCode project. With that the Unity project can access to it. After I just code some interactions between Unity & XCode and never something like this. I suppose you can have more than 1 solutions. Like start Unity with an empty scene which call your app, when your app send the UnitySend$$anonymous$$essage(your parameters), Unity catch this callback and continue with the good mod.
Other solution but I never do this so I don't know if it's possible but I think yes. You can modify your XCode project to start with your Objective-C program and the user choose its mod, the Unity apps start (But I don't know if it's possible) You must probably create a plugin then modify the AppController.mm or something like this. I can check how to do this when I will be at the office. I work on iOS project cause here I don't have any $$anonymous$$AC.
Your answer
Follow this Question
Related Questions
Is there a way to tell in Unity iOS when onDidReceiveMemoryWarning is received? 3 Answers
VideoPlayer from URL has extremely low frame rate in iOS 1 Answer
Videoplayer URL choppy on iOS 0 Answers
WWW Request for image error, unsupported URL 1 Answer
Does unity change AppController.mm or is it the same every time? 1 Answer