Wednesday, 15 May 2013

Application.OpenURL vs Application.ExternalEval

To address one of the problems mentioned in the previous post, the fact that Application.OpenURL only opens the website in the current browser window rather than in a new tab, I did some research on the Unity Community forums and found the using Application.ExternalEval will actually open the page in a new tab, so it is less disruptive to the enjoyment of the viewer. Here is the code I used:

 function OnMouseUp()
    {
    Application.ExternalEval("window.open('http://www.youtube.com','YouTube')");
    }

And the code I replaced:

 function OnMouseUp()
{
    Application.OpenURL('http://www.youtube.com');
}

I still haven't attached it to my own website though. That will be next.

Note: Since originally creating this post, I have added functionality allowing for a page of the project to be opened rather than YouTube, calling the file from my folder structure like so:

 Application.ExternalEval("window.open('../../K00123456_Project_2013/macehead.html','Macehead')");

No comments:

Post a Comment