Is there a script to check if your game has been pirated

I want to check and see if my game has been pirated so that I can disable the game by destroying all of the game objects using javascript

I don’t know a “total answer” (I don’t think there is one), but:
you can add a test to detect your application/player’s location at startup.

string vAddress=Application.absoluteURL;
		string vSrc=Application.srcValue;
		string vSite="mysite.com";
		bool vSame=(vAddress==vSrc);
		bool vBad=(!ContainsString(vAddress,vSite));
		if(vBad||vSame){
			if(Application.platform!=RuntimePlatform.WindowsEditor){
				
					//Application.OpenURL("http://www.mysite.com");	
			}
		}

This is for the web, but can also at least check that the game is installed correctly.

With the above data you could probably also check with standalone games to see if a key file that dealt with security was there and the right size (not tampered with). I don’t know what the steam wrapper stuff looks like, but once you’ve tested the game, you might be able to get your game “sniff it out, and make sure it looks unsuspicious”. I don’t know the exact code you’d use.

If you really want you can call the web with something like, or involving your IP address and get players to register and validate their game (bad if you want offline play). Youd then return an “OK” if your php recognised the IP address, and “bad” if not.

You wouldn’t delete game objects if you suspect piracy, you should just shut down the game.
anything in your game like this shouldn’t be left open to let hackers try and figure out what’s stopping them, just “get them out fast” imho.

Although this kind of question has been ask again and again, and there really isn’t much to do. However, in Android, you can at least detect if the apk has been changed (unzip and zip again). Using following code the detect the signature of the apk:

	public static int GetSignatureHash ()
	{
#if !UNITY_EDITOR && UNITY_ANDROID
		try {
			using (AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer")) {
				using (AndroidJavaObject curActivity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity")) {
					using (AndroidJavaObject packageManager = curActivity.Call<AndroidJavaObject> ("getPackageManager")) {
						// Get Android application name
						string packageName = curActivity.Call<string> ("getPackageName");
						// Get Signature
						int signatureInt = packageManager.GetStatic<int> ("GET_SIGNATURES");  
						using (AndroidJavaObject packageInfo = packageManager.Call<AndroidJavaObject> ("getPackageInfo", packageName, signatureInt)) {
							AndroidJavaObject[] signatures = packageInfo.Get<AndroidJavaObject[]> ("signatures");  
							// return Signature hash
							if (signatures != null && signatures.Length > 0) {
								int hashCode = signatures[0].Call<int> ("hashCode");  
								return hashCode;
							}
						}
					}
				}
			}
		} catch (System.Exception e) {
			Debug.Log (e);
			return 0;
		}

		return 0;
#endif
		return 0;
	}

}

Get the constant signature of your own apk (e.g. 12345678), it won’t be changed as long as you using the same keystore, and compare the signature of the player’s apk:

if (GetSignatureHash () != 12345678)
  IAmHackApk ();

Never actually tried this in build… but it may work. (Not to check for piracy but to help deal with pirates).

DestroyImmediate can destroy assets, so you can use this to destroy the installation, supposedly.

I dont believe there is a solid “One solution fits all” in this case as checking for piracy can be store dependent.

Take Android for instance. Google Dev Console has an “Enable Anti-piracy” option apparently. However, despite this I can pop my details in to Google+ and suddenly I can download all my Google Play content on to my friends’ devices. They didnt buy it. Does that mean it was pirated? No. The fact is that in this case Google have allowed this mechanic. There’s no receipt or stub or hash to check against for the game installed on my friend’s device and the game remains playable even after I remove my account from the device. So how would a piracy check work in this instance?

Realistically, the only thing that can really help with Piracy these days is DRM and you know how much we all apparently hate that. A multiplayer game has the advantage here as they are presumed to always be connected to the internet. In this case you can check all the players if you really wanted.

Its DRM that allowed Croteam to troll their pirates, because they had a good idea in advance what platforms they would be selling from. Back in the day when everything was standalone it was a more difficult issue. Back then it resulted in a “LaserLock” file that stopped your CD-writer responding when it tried to write that particular file so stopping someone from copying a CD.

Or you can think back to humble Worms on the Amiga which came with a code sheet which was black with shiny letters so you couldnt photocopy it.

Piracy is a large topic and as such there is no ‘Insert-script’ solution. This is simply because as soon as said script is discovered it will be broken.

GOG let you download and install Witcher 3 on release but it was a broken game until you installed the Patch file from the site which made it work.

Realistically though, game Publishers account for piracy these days in their figures. They already know that all their games are going to be pirated so they account for it in their profit forecasts.

You get a lot of results from a search on this topic but nothing really solid. Really, you have to get creative. Unless you want to manually verify every user you will need an automated system; but that will just be hacked if you have a half-decent game. Large publishers obviously have the advantage here as they have a lot of money to throw at the problem. Despite this, all their games are still pirated.

Diablo 2 checked against all installation serial numbers that were connected and duplicates were not allowed. You couldnt play on Closed Battle.Net with a pirated D2 copy. Quake 3 Arena had a serial number system but once you had inserted your serial number just one time, you could change it to whatever you wanted and it would still register as valid. This allowed one disk to be used on multiple machines so everyone could play together on a LAN. This was an allowed mechanic. These are opposite approaches, as such, but both seem to work at disarming pirates.

Every version of Borderlands on PC shipped with the same Serial number. you could unlock all the DLCs by adding a 2-line text file to a particular folder. Their ‘anti-piracy’ simply revolved around needing the CD in the tray and having super-anti-copy-protection on the CD itself.

Ultimately, you need to weigh up how much time and money it will take to protect your interests.

This post has a few more ideas in it.