To make it works for different platform it is only necessary to make something like:
if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) {
// TODO - write your code for Windows
} else {
// TODO - write your code for Mac
} // if-else
You can also specify others platform like WindowsWebPlayer, etc.
Pleas enote that the code shown works for Windows executable but also in Unity editor (running on Windows platform).
I hope this can help… if not try to be more specific on your questions !!
Radiolobito, I’ve tried opening an .html file using your code but I must be doing something wrong as the file doesn’t open. I’ve imported the html file into Unity3d’s Asset folder and I have the following code:
if (GUI.Button (Rect(522,710,85,40),"Help"")){
Application.OpenURL ((Application.dataPath)+ "Users/... /Assets/Assets/Help.html");
}
I’m assuming that one has to include the entire path with folder and all the sub-folders (I’ve omitted some of the sub-folders for brevity in the code above) to get it to work. Can you please tell me what I’m doing wrong?
In PC i used to make the folder and contents after publish the game…
In MAC i dont know how to make this, because the folder is an application folder… in PC or Linux you can make that folder, but i dont know the internal folder structure to do this…
sorry but i can’t help you…
if you try to use this command
function OnGUI () {
if (GUI.Button (Rect (250,10,100,30), "Show path")) {
//this can show the path in the Safari, Firefox
Application.OpenURL ("index.html");
//this can show the path in the internal console
print (Application.dataPath);
}
}
hope this can help you… if its working please say us… to apply this in our MAC games
Thanks Radiolobito. Checked the path and it was OK but Safari just doesn’t open. I also checked and popup blocking isn’t on. I’ll just put in a url of an on-line webpage.
If you are trying to open any document using Application.OpenURL then it won’t work. Unity removed that support in latest versions. You can use AndroidOpenUrl.OpenUrl(documentUrl, dataType) for these cases.
public void Example()
{
string dataType = "application/pdf";
string documentUrl = "/storage/emulated/0/Downloads/template.pdf";
AndroidOpenUrl.OpenUrl(documentUrl, dataType); // you can specify any MIME type when opening a file by explicitly specifying the dataType parameter
}
You will get a demo and installation steps of the package from the following repository.