Ejemplo n.º 1
0
    /// <summary>
    /// Encrypted version of EditorPrefs.GetBool(), an unencrypted key is passed and the value is returned decrypted
    /// </summary>
    public static bool GetEncryptedBool(string key, bool defaultValue = false)
    {
        // Encrypt and prefix the key so we can look it up from player prefs
        string encryptedKey = KEY_PREFIX + SimpleEncryption.EncryptString(key);

        // Look up the encrypted value
        string fetchedString = PlayerPrefs.GetString(encryptedKey);

        if (string.IsNullOrEmpty(fetchedString))
        {
            return(defaultValue);
        }

        // Strip out the type identifier character
        fetchedString = fetchedString.Remove(0, 1);

        // Decrypt and return the int value
        return(SimpleEncryption.DecryptBool(fetchedString));
    }