UnityEngine.PlayerPrefs.HasKey(string)

Here are the examples of the csharp api UnityEngine.PlayerPrefs.HasKey(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

66 Examples 7

19 Source : CostumeConeveter.cs
with GNU General Public License v3.0
from aelariane

public static HeroCostume LocalDataToHeroCostume(string slot)
    {
        slot = slot.ToUpper();
        if (!PlayerPrefs.HasKey(slot + PhotonPlayerProperty.sex))
        {
            return HeroCostume.costume[0];
        }
        HeroCostume heroCostume = new HeroCostume();
        heroCostume.sex = IntToSex(PlayerPrefs.GetInt(slot + PhotonPlayerProperty.sex));
        heroCostume.id = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.heroCostumeId);
        heroCostume.costumeId = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.costumeId);
        heroCostume.cape = (PlayerPrefs.GetInt(slot + PhotonPlayerProperty.cape) == 1);
        heroCostume.hairInfo = ((heroCostume.sex != Sex.Male) ? CostumeHair.hairsF[PlayerPrefs.GetInt(slot + PhotonPlayerProperty.hairInfo)] : CostumeHair.hairsM[PlayerPrefs.GetInt(slot + PhotonPlayerProperty.hairInfo)]);
        heroCostume.eye_texture_id = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.eye_texture_id);
        heroCostume.beard_texture_id = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.beard_texture_id);
        heroCostume.glreplaced_texture_id = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.glreplaced_texture_id);
        heroCostume.skin_color = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.skin_color);
        heroCostume.hair_color = new Color(PlayerPrefs.GetFloat(slot + PhotonPlayerProperty.hair_color1), PlayerPrefs.GetFloat(slot + PhotonPlayerProperty.hair_color2), PlayerPrefs.GetFloat(slot + PhotonPlayerProperty.hair_color3));
        heroCostume.division = CostumeConeveter.IntToDivision(PlayerPrefs.GetInt(slot + PhotonPlayerProperty.division));
        heroCostume.stat = new HeroStat();
        heroCostume.stat.Spd = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.statSPD);
        heroCostume.stat.Gas = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.statGAS);
        heroCostume.stat.Bla = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.statBLA);
        heroCostume.stat.Acl = PlayerPrefs.GetInt(slot + PhotonPlayerProperty.statACL);
        heroCostume.stat.skillID = PlayerPrefs.GetString(slot + PhotonPlayerProperty.statSKILL);
        heroCostume.setBodyByCostumeId(-1);
        heroCostume.setMesh();
        heroCostume.setTexture();
        return heroCostume;
    }

19 Source : FengCustomInputs.cs
with GNU General Public License v3.0
from aelariane

private void Start()
    {
        this.inputBool = new bool[this.DescriptionString.Length];
        this.inputString = new string[this.DescriptionString.Length];
        this.inputKey = new KeyCode[this.DescriptionString.Length];
        this.joystickActive = new bool[this.DescriptionString.Length];
        this.joystickString = new string[this.DescriptionString.Length];
        this.isInput = new bool[this.DescriptionString.Length];
        this.isInputDown = new bool[this.DescriptionString.Length];
        this.isInputUp = new bool[this.DescriptionString.Length];
        this.tempLength = PlayerPrefs.GetInt("KeyLength");
        this.tempjoy1 = new bool[this.DescriptionString.Length];
        if (!PlayerPrefs.HasKey("version"))
        {
            this.setToDefault();
        }
        if (UIMainReferences.ConnectField != PlayerPrefs.GetString("version"))
        {
            this.setToDefault();
        }
        this.tempLength = PlayerPrefs.GetInt("KeyLength");
        if (PlayerPrefs.HasKey("KeyCodes") && this.tempLength == this.DescriptionString.Length)
        {
            this.loadConfig();
        }
        else
        {
            this.setToDefault();
        }
        for (int i = 0; i < this.DescriptionString.Length; i++)
        {
            this.isInput[i] = false;
            this.isInputDown[i] = false;
            this.isInputUp[i] = false;
            this.tempjoy1[i] = true;
        }
    }

19 Source : custom_inputs.cs
with GNU General Public License v3.0
from aelariane

private void Start()
    {
        if (this.alt_default_inputKeys.Length == this.default_inputKeys.Length)
        {
            this.altInputson = true;
        }
        this.inputBool = new bool[this.DescriptionString.Length];
        this.inputString = new string[this.DescriptionString.Length];
        this.inputKey = new KeyCode[this.DescriptionString.Length];
        this.joystickActive = new bool[this.DescriptionString.Length];
        this.joystickString = new string[this.DescriptionString.Length];
        this.inputBool2 = new bool[this.DescriptionString.Length];
        this.inputString2 = new string[this.DescriptionString.Length];
        this.inputKey2 = new KeyCode[this.DescriptionString.Length];
        this.joystickActive2 = new bool[this.DescriptionString.Length];
        this.joystickString2 = new string[this.DescriptionString.Length];
        this.isInput = new bool[this.DescriptionString.Length];
        this.isInputDown = new bool[this.DescriptionString.Length];
        this.isInputUp = new bool[this.DescriptionString.Length];
        this.tempLength = PlayerPrefs.GetInt("KeyLength");
        this.tempjoy1 = new bool[this.DescriptionString.Length];
        this.tempjoy2 = new bool[this.DescriptionString.Length];
        if (!PlayerPrefs.HasKey("KeyCodes") || !PlayerPrefs.HasKey("KeyCodes2"))
        {
            this.reset2defaults();
        }
        this.tempLength = PlayerPrefs.GetInt("KeyLength");
        if (PlayerPrefs.HasKey("KeyCodes") && this.tempLength == this.DescriptionString.Length)
        {
            this.loadConfig();
        }
        else
        {
            PlayerPrefs.DeleteAll();
            this.reset2defaults();
            this.loadConfig();
            this.saveInputs();
        }
        for (int i = 0; i < this.DescriptionString.Length; i++)
        {
            this.isInput[i] = false;
            this.isInputDown[i] = false;
            this.isInputUp[i] = false;
            this.tempjoy1[i] = true;
            this.tempjoy2[i] = false;
        }
    }

19 Source : UIInputSaved.cs
with GNU General Public License v3.0
from aelariane

private void Awake()
    {
        this.onSubmit = new UIInput.OnSubmit(this.SaveToPlayerPrefs);
        if (!string.IsNullOrEmpty(this.playerPrefsField) && PlayerPrefs.HasKey(this.playerPrefsField))
        {
            this.text = PlayerPrefs.GetString(this.playerPrefsField);
        }
    }

19 Source : BTN_ToJoin.cs
with GNU General Public License v3.0
from aelariane

private void OnClick()
    {
        NGUITools.SetActive(base.transform.parent.gameObject, false);
        NGUITools.SetActive(UIMainReferences.Main.PanelMultiJoinPrivate, true);
        CacheGameObject.Find("LabelJoinInfo").GetComponent<UILabel>().text = string.Empty;
        if (PlayerPrefs.HasKey("lastIP"))
        {
            CacheGameObject.Find("InputIP").GetComponent<UIInput>().label.text = PlayerPrefs.GetString("lastIP");
        }
        if (PlayerPrefs.HasKey("lastPort"))
        {
            CacheGameObject.Find("InputPort").GetComponent<UIInput>().label.text = PlayerPrefs.GetString("lastPort");
        }
    }

19 Source : CB_cameraTilt.cs
with GNU General Public License v3.0
from aelariane

private void OnActivate(bool result)
    {
        if (!this.init)
        {
            this.init = true;
            if (PlayerPrefs.HasKey("cameraTilt"))
            {
                base.gameObject.GetComponent<UICheckbox>().isChecked = (PlayerPrefs.GetInt("cameraTilt") == 1);
            }
            else
            {
                PlayerPrefs.SetInt("cameraTilt", 1);
            }
        }
        else
        {
            PlayerPrefs.SetInt("cameraTilt", (!result) ? 0 : 1);
        }
        IN_GAME_MAIN_CAMERA.cameraTilt = PlayerPrefs.GetInt("cameraTilt");
    }

19 Source : CheckBoxCamera.cs
with GNU General Public License v3.0
from aelariane

private void Start()
    {
        if (PlayerPrefs.HasKey("cameraType"))
        {
            if (this.camera.ToString().ToUpper() == PlayerPrefs.GetString("cameraType").ToUpper())
            {
                base.GetComponent<UICheckbox>().isChecked = true;
            }
            else
            {
                base.GetComponent<UICheckbox>().isChecked = false;
            }
        }
    }

19 Source : LanguageChangeListener.cs
with GNU General Public License v3.0
from aelariane

private void Start()
    {
        if (Language.type == -1)
        {
            if (PlayerPrefs.HasKey("language"))
            {
                Language.type = PlayerPrefs.GetInt("language");
            }
            else
            {
                PlayerPrefs.SetInt("language", 0);
                Language.type = 0;
            }
            Language.init();
            base.GetComponent<UIPopupList>().selection = Language.GetLang(Language.type);
        }
        else
        {
            base.GetComponent<UIPopupList>().selection = Language.GetLang(Language.type);
        }
    }

19 Source : PopListCamera.cs
with GNU General Public License v3.0
from aelariane

private void Awake()
    {
        if (PlayerPrefs.HasKey("cameraType"))
        {
            base.GetComponent<UIPopupList>().selection = PlayerPrefs.GetString("cameraType");
        }
    }

19 Source : SliderCameraDist.cs
with GNU General Public License v3.0
from aelariane

private void OnSliderChange(float value)
    {
        if (!this.init)
        {
            this.init = true;
            if (PlayerPrefs.HasKey("cameraDistance"))
            {
                float @float = PlayerPrefs.GetFloat("cameraDistance");
                base.gameObject.GetComponent<UISlider>().sliderValue = @float;
                value = @float;
            }
            else
            {
                PlayerPrefs.SetFloat("cameraDistance", base.gameObject.GetComponent<UISlider>().sliderValue);
            }
        }
        else
        {
            PlayerPrefs.SetFloat("cameraDistance", base.gameObject.GetComponent<UISlider>().sliderValue);
        }
        IN_GAME_MAIN_CAMERA.cameraDistance = 0.3f + value;
    }

19 Source : SliderMouseSensitivity.cs
with GNU General Public License v3.0
from aelariane

private void OnSliderChange()
    {
        if (!this.init)
        {
            this.init = true;
            if (PlayerPrefs.HasKey("MouseSensitivity"))
            {
                base.gameObject.GetComponent<UISlider>().sliderValue = PlayerPrefs.GetFloat("MouseSensitivity");
            }
            else
            {
                PlayerPrefs.SetFloat("MouseSensitivity", base.gameObject.GetComponent<UISlider>().sliderValue);
            }
        }
        else
        {
            PlayerPrefs.SetFloat("MouseSensitivity", base.gameObject.GetComponent<UISlider>().sliderValue);
        }
        //IN_GAME_MAIN_CAMERA.sensitivityMulti = PlayerPrefs.GetFloat("MouseSensitivity");
    }

19 Source : ChangeQuality.cs
with GNU General Public License v3.0
from aelariane

private void OnSliderChange()
    {
        if (!this.init)
        {
            this.init = true;
            if (PlayerPrefs.HasKey("GameQuality"))
            {
                base.gameObject.GetComponent<UISlider>().sliderValue = PlayerPrefs.GetFloat("GameQuality");
            }
            else
            {
                PlayerPrefs.SetFloat("GameQuality", base.gameObject.GetComponent<UISlider>().sliderValue);
            }
        }
        else
        {
            PlayerPrefs.SetFloat("GameQuality", base.gameObject.GetComponent<UISlider>().sliderValue);
        }
        ChangeQuality.setQuality(base.gameObject.GetComponent<UISlider>().sliderValue);
    }

19 Source : CB_invertMouseY.cs
with GNU General Public License v3.0
from aelariane

private void OnActivate(bool result)
    {
        if (!this.init)
        {
            this.init = true;
            if (PlayerPrefs.HasKey("invertMouseY"))
            {
                base.gameObject.GetComponent<UICheckbox>().isChecked = (PlayerPrefs.GetInt("invertMouseY") == -1);
            }
            else
            {
                PlayerPrefs.SetInt("invertMouseY", 1);
            }
        }
        else
        {
            PlayerPrefs.SetInt("invertMouseY", (!result) ? 1 : -1);
        }
        IN_GAME_MAIN_CAMERA.invertY = PlayerPrefs.GetInt("invertMouseY");
    }

19 Source : CheckBoxEnableSS.cs
with GNU General Public License v3.0
from aelariane

private void Start()
    {
        this.init = true;
        if (PlayerPrefs.HasKey("EnableSS"))
        {
            if (PlayerPrefs.GetInt("EnableSS") == 1)
            {
                base.GetComponent<UICheckbox>().isChecked = true;
            }
            else
            {
                base.GetComponent<UICheckbox>().isChecked = false;
            }
        }
        else
        {
            base.GetComponent<UICheckbox>().isChecked = true;
            PlayerPrefs.SetInt("EnableSS", 1);
        }
    }

19 Source : CheckBoxShowSSInGame.cs
with GNU General Public License v3.0
from aelariane

private void Start()
    {
        this.init = true;
        if (PlayerPrefs.HasKey("showSSInGame"))
        {
            if (PlayerPrefs.GetInt("showSSInGame") == 1)
            {
                base.GetComponent<UICheckbox>().isChecked = true;
            }
            else
            {
                base.GetComponent<UICheckbox>().isChecked = false;
            }
        }
        else
        {
            base.GetComponent<UICheckbox>().isChecked = true;
            PlayerPrefs.SetInt("showSSInGame", 1);
        }
    }

19 Source : MotionCamera.cs
with MIT License
from BelkinAndrey

void Start() 
    {
        if (PlayerPrefs.HasKey("StartZoom")) Zoom = PlayerPrefs.GetFloat("StartZoom");
        else Zoom = StartZoom;
        if (PlayerPrefs.HasKey("CamX") && PlayerPrefs.HasKey("CamY") && PlayerPrefs.HasKey("CamZ")) transform.position =
            new Vector3(PlayerPrefs.GetFloat("CamX"), PlayerPrefs.GetFloat("CamY"), PlayerPrefs.GetFloat("CamZ"));
    }

19 Source : SaveOpen.cs
with MIT License
from BelkinAndrey

void Start()
    {
        if (PlayerPrefs.HasKey("Path")) PathFile = PlayerPrefs.GetString("Path"); // PlayerPrefs для пути к файлу.
        if (PathFile != "")
        {
            if (File.Exists(Application.dataPath + "/Data/" + PathFile + ".tad"))
            {
               Load(); 
            }
        }
    }

19 Source : LoadBrain.cs
with MIT License
from BelkinAndrey

void Start()
    {
        if (PlayerPrefs.HasKey("Path")) PathFile = PlayerPrefs.GetString("Path"); // PlayerPrefs для пути к файлу.
        if (PathFile != "")
        {
            if (File.Exists(Application.dataPath + "/Data/" + PathFile + ".tad"))
            {
                Load();
            }
            else 
            {
                errorText.enabled = true;
            }
        }
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static string[] GetStringArray(string key, string defaultValue, int defaultSize)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetStringArray(key);
        }

        var stringArray = new string[defaultSize];
        for (int i = 0; i < defaultSize; i++)
        {
            stringArray[i] = defaultValue;
        }

        return stringArray;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static string[] GetStringArray(string key, string[] defaultArray)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetStringArray(key);
        }

        return defaultArray;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static int[] GetIntArray(string key, int defaultValue, int defaultSize)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetIntArray(key);
        }

        var intArray = new int[defaultSize];
        for (int i = 0; i < defaultSize; i++)
        {
            intArray[i] = defaultValue;
        }

        return intArray;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static Vector2[] GetVector2Array(string key, Vector2 defaultValue, int defaultSize)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetVector2Array(key);
        }

        var vector2Array = new Vector2[defaultSize];
        for (int i = 0; i < defaultSize; i++)
        {
            vector2Array[i] = defaultValue;
        }

        return vector2Array;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static Quaternion[] GetQuaternionArray(string key, Quaternion defaultValue, int defaultSize)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetQuaternionArray(key);
        }

        var quaternionArray = new Quaternion[defaultSize];
        for (int i = 0; i < defaultSize; i++)
        {
            quaternionArray[i] = defaultValue;
        }

        return quaternionArray;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

private static void GetValue<T>(string key, T list, ArrayType arrayType, int vectorNumber,
        Action<T, byte[]> convert) where T : IList
    {
        if (PlayerPrefs.HasKey(key))
        {
            var bytes = Convert.FromBase64String(PlayerPrefs.GetString(key));
            if ((bytes.Length - 1) % (vectorNumber * 4) != 0)
            {
                Debug.LogError("Corrupt preference file for " + key);
                return;
            }

            if ((ArrayType) bytes[0] != arrayType)
            {
                Debug.LogError(key + " is not a " + arrayType + " array");
                return;
            }

            Initialize();

            var end = (bytes.Length - 1) / (vectorNumber * 4);
            for (var i = 0; i < end; i++)
            {
                convert(list, bytes);
            }
        }
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static bool GetBool(string name, bool defaultValue)
    {
        return PlayerPrefs.HasKey(name) ? GetBool(name) : defaultValue;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static float[] GetFloatArray(string key, float defaultValue, int defaultSize)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetFloatArray(key);
        }

        var floatArray = new float[defaultSize];
        for (int i = 0; i < defaultSize; i++)
        {
            floatArray[i] = defaultValue;
        }

        return floatArray;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static bool[] GetBoolArray(string key, bool defaultValue, int defaultSize)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetBoolArray(key);
        }

        var boolArray = new bool[defaultSize];
        for (int i = 0; i < defaultSize; i++)
        {
            boolArray[i] = defaultValue;
        }

        return boolArray;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static string[] GetStringArray(string key)
    {
        if (PlayerPrefs.HasKey(key))
        {
            var completeString = PlayerPrefs.GetString(key);
            var separatorIndex = completeString.IndexOf("|"[0]);
            if (separatorIndex < 4)
            {
                Debug.LogError("Corrupt preference file for " + key);
                return new string[0];
            }

            var bytes = Convert.FromBase64String(completeString.Substring(0, separatorIndex));
            if ((ArrayType) bytes[0] != ArrayType.String)
            {
                Debug.LogError(key + " is not a string array");
                return new string[0];
            }

            Initialize();

            var numberOfEntries = bytes.Length - 1;
            var stringArray = new string[numberOfEntries];
            var stringIndex = separatorIndex + 1;
            for (var i = 0; i < numberOfEntries; i++)
            {
                int stringLength = bytes[idx++];
                if (stringIndex + stringLength > completeString.Length)
                {
                    Debug.LogError("Corrupt preference file for " + key);
                    return new string[0];
                }

                stringArray[i] = completeString.Substring(stringIndex, stringLength);
                stringIndex += stringLength;
            }

            return stringArray;
        }

        return new string[0];
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static Vector3[] GetVector3Array(string key, Vector3 defaultValue, int defaultSize)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetVector3Array(key);
        }

        var vector3Array = new Vector3[defaultSize];
        for (int i = 0; i < defaultSize; i++)
        {
            vector3Array[i] = defaultValue;
        }

        return vector3Array;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static Color GetColor(string key, Color defaultValue)
    {
        return PlayerPrefs.HasKey(key) ? GetColor(key) : defaultValue;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static Color GetColor(string key, string defaultValue)
    {
        return PlayerPrefs.HasKey(key) ? GetColor(key) : defaultValue.ToColor();
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static Vector2 GetVector2(string key, Vector2 defaultValue)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetVector2(key);
        }

        return defaultValue;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static Vector3 GetVector3(string key, Vector3 defaultValue)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetVector3(key);
        }

        return defaultValue;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static Quaternion GetQuaternion(string key, Quaternion defaultValue)
    {
        if (PlayerPrefs.HasKey(key))
        {
            return GetQuaternion(key);
        }

        return defaultValue;
    }

19 Source : PlayerPrefsExtensions.cs
with GNU General Public License v3.0
from Cytoid

public static bool[] GetBoolArray(string key)
    {
        if (!PlayerPrefs.HasKey(key)) return new bool[0];
        var bytes = Convert.FromBase64String(PlayerPrefs.GetString(key));
        if (bytes.Length < 5)
        {
            Debug.LogError("Corrupt preference file for " + key);
            return new bool[0];
        }

        if ((ArrayType) bytes[0] != ArrayType.Bool)
        {
            Debug.LogError(key + " is not a boolean array");
            return new bool[0];
        }

        Initialize();

        // Make a new bytes array that doesn't include the number of entries + identifier (first 5 bytes) and turn that into a BitArray
        var bytes2 = new byte[bytes.Length - 5];
        Array.Copy(bytes, 5, bytes2, 0, bytes2.Length);
        var bits = new BitArray(bytes2) {Length = ConvertBytesToInt32(bytes)};
        // Get the number of entries from the first 4 bytes after the identifier and resize the BitArray to that length, then convert it to a boolean array
        var boolArray = new bool[bits.Count];
        bits.CopyTo(boolArray, 0);

        return boolArray;

    }

19 Source : UIInput.cs
with MIT License
from mamoniem

public void LoadValue ()
	{
		if (!string.IsNullOrEmpty(savedAs))
		{
			string val = mValue.Replace("\\n", "\n");
			mValue = "";
			value = PlayerPrefs.HasKey(savedAs) ? PlayerPrefs.GetString(savedAs) : val;
		}
	}

19 Source : PlayerSaves.cs
with MIT License
from ookii-tsuki

public static T DecryptClreplaced<T>(string prefKey) where T : clreplaced
        {
            if (PlayerPrefs.HasKey(prefKey))
            {
                var data = DecryptText(PlayerPrefs.GetString(prefKey));
                return JsonUtility.FromJson<T>(data);
            }
            return null;
        }

19 Source : PlayerSaves.cs
with MIT License
from ookii-tsuki

public static void DecryptClreplacedOverwrite<T>(T obj, string prefKey)
        {
            if (PlayerPrefs.HasKey(prefKey))
            {
                var data = DecryptText(PlayerPrefs.GetString(prefKey));
                JsonUtility.FromJsonOverwrite(data, obj);
            }
        }

19 Source : PlayerSaves.cs
with MIT License
from ookii-tsuki

public static bool HasPrefKey(string prefKey) => PlayerPrefs.HasKey(prefKey);

19 Source : MapManager.cs
with MIT License
from silverua

private void Start()
        {
            if (PlayerPrefs.HasKey("Map"))
            {
                var mapJson = PlayerPrefs.GetString("Map");
                var map = JsonConvert.DeserializeObject<Map>(mapJson);
                // using this instead of .Contains()
                if (map.path.Any(p => p.Equals(map.GetBossNode().point)))
                {
                    // payer has already reached the boss, generate a new map
                    GenerateNewMap();
                }
                else
                {
                    CurrentMap = map;
                    // player has not reached the boss yet, load the current map
                    view.ShowMap(map);
                }
            }
            else
            {
                GenerateNewMap();
            }
        }

19 Source : WalletConnect.cs
with MIT License
from WalletConnect

private void SessionOnOnSessionDisconnect(object sender, EventArgs e)
        {
            if (autoSaveAndResume && PlayerPrefs.HasKey(SessionKey))
            {
                PlayerPrefs.DeleteKey(SessionKey);
            }
        }

19 Source : WalletConnect.cs
with MIT License
from WalletConnect

private async void OnApplicationPause(bool pauseStatus)
        {
            if (pauseStatus)
            {
                await SaveOrDisconnect();
            }
            else if (PlayerPrefs.HasKey(SessionKey) && autoSaveAndResume)
            {
                await Connect();
            }
        }

19 Source : WalletConnect.cs
with MIT License
from WalletConnect

public async Task<WCSessionData> Connect()
        {
            SavedSession savedSession = null;
            if (PlayerPrefs.HasKey(SessionKey))
            {
                var json = PlayerPrefs.GetString(SessionKey);
                savedSession = JsonConvert.DeserializeObject<SavedSession>(json);
            }
            
            if (string.IsNullOrWhiteSpace(customBridgeUrl))
            {
                customBridgeUrl = null;
            }
            
            if (Session != null)
            {
                var currentKey = Session.KeyData;
                if (savedSession != null)
                {
                    if (currentKey != savedSession.Key)
                    {
                        if (Session.Connected)
                        {
                            await Session.Disconnect();
                        }
                        else if (Session.TransportConnected)
                        {
                            await Session.Transport.Close();
                        }
                    }
                    else if (!Session.Connected && !Session.Connecting)
                    {
                        StartCoroutine(SetupDefaultWallet());

                        #if UNITY_ANDROID || UNITY_IOS
                        //Whenever we send a request to the Wallet, we want to open the Wallet app
                        Session.OnSend += (sender, session) => OpenMobileWallet();
                        #endif

                        return await CompleteConnect();
                    }
                    else
                    {
                        return null; //Nothing to do
                    }
                }
                else if (Session.Connected)
                {
                    await Session.Disconnect();
                }
                else if (Session.TransportConnected)
                {
                    await Session.Transport.Close();
                } 
                else if (Session.Connecting)
                {
                    //We are still connecting, do nothing
                    return null;
                }
            }

            //default will be set by library
            ICipher ciper = null;
            
            #if UNITY_WEBGL
            ciper = new WebGlAESCipher();
            #endif
            
            if (savedSession != null)
            {
                Session = new WalletConnectUnitySession(savedSession, this, _transport);
            }
            else
            {
                Session = new WalletConnectUnitySession(AppData, this, customBridgeUrl, _transport, ciper, chainId);
            }
            
            Session.OnSessionDisconnect += SessionOnOnSessionDisconnect;
            
            StartCoroutine(SetupDefaultWallet());

            #if UNITY_ANDROID || UNITY_IOS
            //Whenever we send a request to the Wallet, we want to open the Wallet app
            Session.OnSend += (sender, session) => OpenMobileWallet();
            #endif

            return await CompleteConnect();
        }

19 Source : HasKey.cs
with MIT License
from XINCGer

public override TaskStatus OnUpdate()
        {
            return PlayerPrefs.HasKey(key.Value) ? TaskStatus.Success : TaskStatus.Failure;
        }

19 Source : LargeFileDownloadSample.cs
with MIT License
from XINCGer

void OnGUI()
        {
            GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
                {
                    // Draw the current status
                    GUILayout.Label("Request status: " + status);

                    GUILayout.Space(5);

                    // Draw the current progress
                    GUILayout.Label(string.Format("Progress: {0:P2} of {1:N0}Mb", progress, PlayerPrefs.GetInt("DownloadLength") / 1048576 /*1 Mb*/));
                    GUILayout.HorizontalSlider(progress, 0, 1);

                    GUILayout.Space(50);

                    if (request == null)
                    {
                        // Draw a slider to be able to change the fragment size
                        GUILayout.Label(string.Format("Desired Fragment Size: {0:N} KBytes", fragmentSize / 1024f));
                        fragmentSize = (int)GUILayout.HorizontalSlider(fragmentSize, HTTPResponse.MinBufferSize, 10 * 1024 * 1024);

                        GUILayout.Space(5);

                        string buttonStr = PlayerPrefs.HasKey("DownloadProgress") ? "Continue Download" : "Start Download";
                        if (GUILayout.Button(buttonStr))
                            StreamLargeFileTest();
                    }
                    else if (request.State == HTTPRequestStates.Processing && GUILayout.Button("Abort Download"))
                    {
                        // Simulate a connection lost
                        request.Abort();
                    }
                });
        }

19 Source : LargeFileDownloadSample.cs
with MIT License
from XINCGer

void StreamLargeFileTest()
        {
            request = new HTTPRequest(new Uri(URL), (req, resp) =>
            {
                switch (req.State)
                {
                    // The request is currently processed. With UseStreaming == true, we can get the streamed fragments here
                    case HTTPRequestStates.Processing:

                        // Set the DownloadLength, so we can display the progress
                        if (!PlayerPrefs.HasKey("DownloadLength"))
                        {
                            string value = resp.GetFirstHeaderValue("content-length");
                            if (!string.IsNullOrEmpty(value))
                                PlayerPrefs.SetInt("DownloadLength", int.Parse(value));
                        }

                        // Get the fragments, and save them
                        ProcessFragments(resp.GetStreamedFragments());

                        status = "Processing";
                        break;

                    // The request finished without any problem.
                    case HTTPRequestStates.Finished:
                        if (resp.IsSuccess)
                        {
                            // Save any remaining fragments
                            ProcessFragments(resp.GetStreamedFragments());

                            // Completely finished
                            if (resp.IsStreamingFinished)
                            {
                                status = "Streaming finished!";

                                // We are done, delete the progress key
                                PlayerPrefs.DeleteKey("DownloadProgress");
                                PlayerPrefs.Save();

                                request = null;
                            }
                            else
                                status = "Processing";
                        }
                        else
                        {
                            status = string.Format("Request finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
                                                            resp.StatusCode,
                                                            resp.Message,
                                                            resp.DataAsText);
                            Debug.LogWarning(status);

                            request = null;
                        }
                        break;

                    // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
                    case HTTPRequestStates.Error:
                        status = "Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception");
                        Debug.LogError(status);

                        request = null;
                        break;

                    // The request aborted, initiated by the user.
                    case HTTPRequestStates.Aborted:
                        status = "Request Aborted!";
                        Debug.LogWarning(status);

                        request = null;
                        break;

                    // Connecting to the server is timed out.
                    case HTTPRequestStates.ConnectionTimedOut:
                        status = "Connection Timed Out!";
                        Debug.LogError(status);

                        request = null;
                        break;

                    // The request didn't finished in the given time.
                    case HTTPRequestStates.TimedOut:
                        status = "Processing the request Timed Out!";
                        Debug.LogError(status);

                        request = null;
                        break;
                }
            });

            // Are there any progress, that we can continue?
            if (PlayerPrefs.HasKey("DownloadProgress"))
                // Set the range header
                request.SetRangeHeader(PlayerPrefs.GetInt("DownloadProgress"));
            else
                // This is a new request
                PlayerPrefs.SetInt("DownloadProgress", 0);

#if !BESTHTTP_DISABLE_CACHING && (!UNITY_WEBGL || UNITY_EDITOR)
            // If we are writing our own file set it true(disable), so don't duplicate it on the file-system
            request.DisableCache = true;
#endif

            // We want to access the downloaded bytes while we are still downloading
            request.UseStreaming = true;

            // Set a reasonable high fragment size. Here it is 5 megabytes.
            request.StreamFragmentSize = fragmentSize;

            // Start Processing the request
            request.Send();
        }

19 Source : SocketIOWePlaySample.cs
with MIT License
from XINCGer

private void OnConnected(Socket socket, Packet packet, params object[] args)
    {
        if (PlayerPrefs.HasKey("Nick"))
        {
            Nick = PlayerPrefs.GetString("Nick", "NickName");
            Join();
        }
        else
            State = States.WaitForNick;

        AddMessage("connected");
    }

19 Source : LargeFileDownloadSample.cs
with MIT License
from XINCGer

void Awake()
        {
            // If we have a non-finished download, set the progress to the value where we left it
            if (PlayerPrefs.HasKey("DownloadLength"))
                progress = PlayerPrefs.GetInt("DownloadProgress") / (float)PlayerPrefs.GetInt("DownloadLength");
        }

19 Source : ConnectionAPISample.cs
with MIT License
from XINCGer

void Start()
    {
#if !BESTHTTP_DISABLE_COOKIES && (!UNITY_WEBGL || UNITY_EDITOR)
        // Set a "user" cookie if we previously used the 'Enter Name' button.
        // The server will set this username to the new connection.
        if (PlayerPrefs.HasKey("userName"))
            CookieJar.Set(URI, new Cookie("user", PlayerPrefs.GetString("userName")));
#endif

        signalRConnection = new Connection(URI);

        // to serialize the Message clreplaced, set a more advanced json encoder
        signalRConnection.JsonEncoder = new BestHTTP.SignalR.JsonEncoders.LitJsonEncoder();

        // set up event handlers
        signalRConnection.OnStateChanged += signalRConnection_OnStateChanged;
        signalRConnection.OnNonHubMessage += signalRConnection_OnGeneralMessage;

        // Start to connect to the server.
        signalRConnection.Open();
    }

19 Source : UnityEngine_PlayerPrefsWrap.cs
with MIT License
from XINCGer

[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
	static int HasKey(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 1);
			string arg0 = ToLua.CheckString(L, 1);
			bool o = UnityEngine.PlayerPrefs.HasKey(arg0);
			LuaDLL.lua_pushboolean(L, o);
			return 1;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}

See More Examples