123456789101112131415161718192021222324252627282930313233 |
- using UnityEngine;
- using System.Collections;
- public class SecureIntValue
- {
- string name;
- int salt;
- int multiplier;
- public SecureIntValue(string name, int salt, int multiplier, int defaultValue)
- {
- this.name = name;
- this.salt = salt;
- this.multiplier = multiplier;
- if (!PlayerPrefs.HasKey(name))
- {
- Value = defaultValue;
- }
- }
- public int Value
- {
- get
- {
- return (PlayerPrefs.GetInt(name, salt) - salt)/multiplier;
- }
- set
- {
- PlayerPrefs.SetInt(name, (value * multiplier) + salt);
- PlayerPrefs.Save();
- }
- }
- }
|