Launching OSX app created with Unity from custom URL scheme

706 Views Asked by At

I'm looking for a way to launch an OSX app(Standalone) created with Unity from a browser using a custom URL scheme.
After add a custom URL scheme to the Info.plist, I can launch the app successfully.
And I want to know how can I get the arguments passed in the URL.(e.g. URLscheme://iwanttoreadthisdata).
Is there any way to do this?

1

There are 1 best solutions below

3
Richard Duerr On

Assuming it's a web GL build, you can find info here: https://answers.unity.com/questions/1285359/how-to-read-url-parameters-from-unity-webgl-build.html

The relevant information references that it's a bit tricky, as they use a JS library to execute in the browser context and extract data as a unity library.

https://github.com/Bunny83/UnityWebExamples/blob/master/Mandelbrot/URLParameters.cs

This looks at normal browser locations, and c# accesses/properties to force the js code to execute as a unity library at runtime. For browser JS code, the URL is window.location.href

And it parses out the data from that string using JS and gives back a dictionary object to unity c# code.

(I understand linking to these might be leading to an external site for answers, but the code is a bit lengthy, and would be redundant to copy/paste other good explanations). Other mods can edit if this is unreasonable.