- Home /
Parse URL passed parameters on Standalone Mac build
I'm trying to make it so players can launch our Unity game from a URL, and to capture the parameters passed. I've gotten as far as registering a URL-scheme handler by editing the info.plist, and that works - the app can launch via a URL in a browser. However, I'm having trouble retrieving the parameters.
I was hoping these would translate to command-line arguments( which Unity can read) - but it doesn't.
It seems that the way to do this on Mac is to register a hook in native code for when the application finishes launching - for instance like this:
http://stackoverflow.com/questions/6561661/url-scheme-qt-and-mac
However, my attempt to do this through a native mac plugins doesn't seem to work - presumably because the event triggered happens before my plugin is loaded.
Does anyone know how to do this? One potential solution I've been considering is to use a separate application to receive the URL, which would then launch my game.
Barring a more elegant solution, could anyone suggest a clean way to do that? Perhaps I could put two executables in the same package and have one trigger the other?
Have you found a nice solution to this issue? Is there a proper way now to achieve launching by url-scheme in Unity 5 now?
HI guys, any solution found? I would need custom url and file association!
Answer by aaronflippo · Jun 30, 2017 at 03:59 PM
I never found a good easy solution. Basically, we made it so when you clicked a button on the webpage, it recorded some info on a server, and triggered the game to launch. Then the game looked for the existence of that chunk of data that was associated with the user's account. It wasn't very elegant.
That's sad that Unity hasn't made Delegates available. I saw a hacking for overriding them, but a commercial app should not be a bunch of hacking. If unity dev just made association and custom url accessible, it would solve 99% of the devs requests.