Your question is not clear, but from what I understand you did a project on Unity3D, compiled for the web (that is, generated the version in WebGL), put it to run on a page of yours, and then tested the your code.
Well, in that case, your code will not even work as you expect it to. According to the Application.OpenURL
documentation, it opens the URL in the default browser, but the result is not specified if the application is running in the browser. Still, I think it's okay to open it in the same frame as the application is running.
If you want more control and external interactions (with JavaScript, for example), use the Application.ExternalEval
. Test your code like this, for example:
using UnityEngine;
using System.Collections;
public class Urlazerecovelo: MonoBehaviour
{
void OnMouseDown()
{
Application.ExternalEval("window.open(\"https://www.google.pt\")");
}
}
Still, interactions between your application and JavaScript should be limited or kept to a minimum. If you are having an effort to build an application in Unity, try to make the most important interactions in it, since only then can you get the portability (that is, run on other platforms), which is just one of the strengths of this tool. >