Protect your on local client existing PlayerPrefs.
Just replace PlayerPrefs with ProtectedPlayerPrefs.
Storable types:
- Bool
- int
- float
- string
- Vector2
- Vector3
- Vector4
- Quaternion
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
// using OPS.AntiCheat; public class ProtectedPlayerPrefsDemo : MonoBehaviour { void Awake () { //Bool ProtectedPlayerPrefs.SetBool("My Bool Key", true); bool protectedBoolValue = ProtectedPlayerPrefs.GetBool("My Bool Key"); Debug.Log("Real Value: " + protectedBoolValue); //Int ProtectedPlayerPrefs.SetInt("My Int Key", 1234); //Adds a _Protected to a protected key name int intValue = PlayerPrefs.GetInt("My Int Key" + "_Protected"); //Because of the added _Protected, you have to read the key plus _Protected Debug.Log("Value saved by Unity: " + intValue); int protectedIntValue = ProtectedPlayerPrefs.GetInt("My Int Key"); Debug.Log("Real Value: " + protectedIntValue); //Float ProtectedPlayerPrefs.SetFloat("My Float Key", 1234.56f); float floatValue = PlayerPrefs.GetInt("My Float Key" + "_Protected"); //Stored inside unity as uint Debug.Log("Value saved by Unity: " + floatValue); float protectedFloatValue = ProtectedPlayerPrefs.GetFloat("My Float Key"); Debug.Log("Real Value: " + protectedFloatValue); //String ProtectedPlayerPrefs.SetString("My String Key", "Hello World!"); string stringValue = PlayerPrefs.GetString("My String Key" + "_Protected"); Debug.Log("Value saved by Unity: " + stringValue); string protectedStringValue = ProtectedPlayerPrefs.GetString("My String Key"); Debug.Log("Real Value: " + protectedStringValue); //Vector2 ProtectedPlayerPrefs.SetVector2("My Vector2 Key", new Vector2(123.55f, -10012.2f)); Vector2 protectedVector2Value = ProtectedPlayerPrefs.GetVector2("My Vector2 Key"); Debug.Log("Real Value: " + protectedVector2Value); //Vector3 ProtectedPlayerPrefs.SetVector3("My Vector3 Key", new Vector3(123.55f, -10012.2f, 771123)); Vector3 protectedVector3Value = ProtectedPlayerPrefs.GetVector3("My Vector3 Key"); Debug.Log("Real Value: " + protectedVector3Value); //Vector4 ProtectedPlayerPrefs.SetVector4("My Vector4 Key", new Vector4(1, 2, 3, 4)); Vector4 protectedVector4Value = ProtectedPlayerPrefs.GetVector4("My Vector4 Key"); Debug.Log("Real Value: " + protectedVector4Value); //Quaternion ProtectedPlayerPrefs.SetQuaternion("My Quaternion Key", new Quaternion(1, 2, 3, 4)); Quaternion protectedQuaternionValue = ProtectedPlayerPrefs.GetQuaternion("My Quaternion Key"); Debug.Log("Real Value: " + protectedQuaternionValue); } } |