- Home /
anti-piracy
How can I make so the buttons are disabled if they don't get the game the right way?
Answer by RyanAtEvno · Mar 29, 2018 at 09:27 PM
On the script attached to your Button game object, Button (Script), there is a component you can access "Intractable". So place this script on your button. Since you cant have a bool in PlayerPref set PremiumIsUnlocked int where 0 equals false and 1 equals true. When they purchase full game or whatever just set PlayerPref.SetInt ("PremiumIsUnlocked", 1);
if (PlayerPref.GetInt ("PremiumIsUnlocked", 0) >= 1)
this.GameObject.GetComponent<Button> ().interactable = true;
else
this.GameObject.GetComponent<Button> ().interactable = true;
}
Thank you and so would I be able to use this on a few things like make a buy now button as well?
If you set a function on your buy now button so that when purchase is complete, it sets PlayerPref.SetInt ("PremiumIsUnlocked", 1).
Answer by Kishotta · Mar 30, 2018 at 12:41 AM
The only way to guarantee an instance of your game is legitimate is by using a web-based login or registration to verify keys.
If you want to go with the "PlayerPrefs" style, I recommend NOT using PlayerPrefs, as it is just a (very user-editable) .txt file stored with the game files. Anyone with notepad could spoof your purchase. Instead, you might want to hide a binary file somewhere in your project that contains a valid/invalid flag. Binary files are still user editable with hex editors, but if the flag is hidden in a bunch of other random data, it could take a while for pirates to find.