- Home /
unity web player security
Is a game that's running in unity web player able to be prevented from being linked into another website and secured against being explicitly downloaded/copied?
Answer by jahroy · Sep 19, 2011 at 09:29 PM
Unity provides at least two methods that can help with this.
The Application.absoluteUrl property will tell you the full URL where your unity3d data file is being hosted. You can use this property to check whether or not your game is being loaded from the correct place. This will help prevent people from downloading your unity3d file and hosting it somewhere else.
There is also the Applicatoin.srcValue property, which will tell you the path used in your html page to identify the unity3d file. You can use this, for example, to ensure that the html page is in the same directory as the unity3d file. This will help prevent people from creating html pages and pointing them at your data.
You can also implement your own security on top of this. We have our data file hosted behind Drupal. Every now and then the Unity game pings the server to make sure the user is valid, the user is logged in, and the user has access to the game in question.
Here is some extremely simple code (almost taken directly from the documentation) that shows how to use these properties:
/* return true if piracy has been detected */
function detectPiracy () : boolean { / only calling this for webplayer right now /
if ( ! Application.isWebPlayer ) {
return false;
}
var urlPath = Application.absoluteURL.ToLower();
var dataPath = Application.srcValue.ToLower();
/* unity3d file must be found in same directory as html file */
if ( dataPath != "mygame.unity3d" ) {
return true;
}
/* html file must be located at myhost.com */
if ( urlPath == "http://myhost.com/some/path/mygame.unity3d" ) {
return false;
}
if ( urlPath == "http://www.myhost.com/some/path/mygame.unity3d" ) {
return false;
}
return true;
}
All of these techniques help prevent people from playing your game if they access it the wrong way. They do not prevent people from downloading it from your site.
Answer by Chambers · Sep 19, 2011 at 03:19 PM
I don't believe so, I think Unity games can be downloaded and re-uploaded to other websites with fairly simple means. I also believe there are methods that assets and code from within Unity projects can be extracted (I think this is an illegal practise however and is frowned upon). I'm afraid the reality is your project is always going to be at risk of being uploaded elsewhere if its on the internet.
Your answer
Follow this Question
Related Questions
Copying Unity project/scenes to another Mac 2 Answers
Standalone Copying Failure 0 Answers
Unity 4.0 mesh duplication possible? 2 Answers
How do I keep a texture different on copied objects? 1 Answer