3iX

Reliable $1 Web Hosting by 3iX

Saturday, September 25, 2010

Executing arbitrary browser code from Unity web player content

You don't even have to define functions in the embedding web page, instead you can use the Application.ExternalEval() function to execute arbitrary browser code from the web player content.
The following example checks that the page embedding the web player content is fetched from a certain host (unity3d.com), if that's not the case then it will redirect to another URL. This technique can be used to prevent deep linking to your web player content:
Application.ExternalEval(
    "if(document.location.host != 'unity3d.com') { document.location='http://unity3d.com'; }"
);

No comments:

Post a Comment