- Home /
Does the Unity player support domain locking?
What I mean by domain locking is keeping someone from downloading my game and host the file on a different domain (url). If it isn't a built in feature, are there scripts available?
Answer by Maarten · Dec 05, 2010 at 07:59 PM
You can do this, just look at the following url: http://unity3d.com/support/documentation/Manual/Unity%20Web%20Player%20and%20browser%20communication.html
Its the most bottom code fragment witch does what you need:
Application.ExternalEval("if(document.location.host != 'YOURDOMAIN.COM') { document.location='WHERE_TO_REDIRECT_YOUR_USER; }");
You can put this code wherever you wish. But i would put it when the first scene is loaded.
Perfect, thank you very much. I looked everywhere for this answer.
Answer by andyman404 · Jan 02, 2015 at 06:29 PM
If you don't want to hardcode URLs into domain checking scripts (see simple one line solution above), here's a simple C# script I've made for Unity that lets you check the domain that the webplayer is running on, against a list of domains.
https://gist.github.com/andyman/e58dea85cce23cccecff
It will redirect to a specified location if the domain is not found. Just drag the script onto a GameObject in your first scene, and set the domains and redirect URL in the properties in the Inspector tab. Feel free to use/share.
I uploaded the web player version of my game to only one site, and within a few days, it was hosted by more than a dozen sites without my permission.
Lesson learned: Put a domain locking script in your game from the onset. Here is my article about the lesson learned.
If you don't $$anonymous$$e me asking, what is the license for the code? I plan on using it in the near future, probably for any WebGL stuff as well.
Your answer
Follow this Question
Related Questions
Web player fails to download data file, IIS 7, MIME problem? hosted at EasySpace.com 2 Answers
Web-server configuration to correctly serve Unity webplayers 4 Answers
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
webplayer wont work on my server? 1 Answer
Need help publishing unity game to personal website 1 Answer