//############################################### Color32 ############################################## //Set an array of Colour32s public static void SetColour32Array(string key, Color32[] value) { PlayerPrefs.SetInt("PlayerPrefsArray:Colour32:L:" + key, value.Length); int i = 0; while (i < value.Length) { PlayerPrefsPlus.SetColour32("PlayerPrefsArray:Colour32:" + key + i.ToString(), value[i]); ++i; } }
//############################################### Rect ############################################## //Set an array of Rects public static void SetRectArray(string key, Rect[] value) { PlayerPrefs.SetInt("PlayerPrefsArray:Rect:L:" + key, value.Length); int i = 0; while (i < value.Length) { PlayerPrefsPlus.SetRect("PlayerPrefsArray:Rect:" + key + i.ToString(), value[i]); ++i; } }
//############################################### bool ############################################## //Set an array of bool public static void SetBoolArray(string key, bool[] value) { PlayerPrefs.SetInt("PlayerPrefsArray:Bool:L:" + key, value.Length); int i = 0; while (i < value.Length) { PlayerPrefsPlus.SetBool("PlayerPrefsArray:Bool:" + key + i.ToString(), value[i]); ++i; } }
//############################################### Quaternion ############################################## //Set an array of Quaternions public static void SetQuaternionArray(string key, Quaternion[] value) { PlayerPrefs.SetInt("PlayerPrefsArray:Quaternion:L:" + key, value.Length); int i = 0; while (i < value.Length) { PlayerPrefsPlus.SetQuaternion("PlayerPrefsArray:Quaternion:" + key + i.ToString(), value[i]); ++i; } }
//############################################### Vector4 ############################################## //Set an array of Vector4s public static void SetVector4Array(string key, Vector4[] value) { PlayerPrefs.SetInt("PlayerPrefsArray:Vector4:L:" + key, value.Length); int i = 0; while (i < value.Length) { PlayerPrefsPlus.SetVector4("PlayerPrefsArray:Vector4:" + key + i.ToString(), value[i]); ++i; } }
//Get an array of Vector4s public static Vector4[] GetVector4Array(string key) { Vector4[] returns = new Vector4[PlayerPrefs.GetInt("PlayerPrefsArray:Vector4:L:" + key)]; int i = 0; while (i < PlayerPrefs.GetInt("PlayerPrefsArray:Vector4:L:" + key)) { returns.SetValue(PlayerPrefsPlus.GetVector4("PlayerPrefsArray:Vector4:" + key + i.ToString()), i); ++i; } return(returns); }
//Get an array of Quaternions public static Quaternion[] GetQuaternionArray(string key) { Quaternion[] returns = new Quaternion[PlayerPrefs.GetInt("PlayerPrefsArray:Quaternion:L:" + key)]; int i = 0; while (i < PlayerPrefs.GetInt("PlayerPrefsArray:Quaternion:L:" + key)) { returns.SetValue(PlayerPrefsPlus.GetQuaternion("PlayerPrefsArray:Quaternion:" + key + i.ToString()), i); ++i; } return(returns); }
//Get an array of Colour32s public static Color32[] GetColour32Array(string key) { Color32[] returns = new Color32[PlayerPrefs.GetInt("PlayerPrefsArray:Colour32:L:" + key)]; int i = 0; while (i < PlayerPrefs.GetInt("PlayerPrefsArray:Colour32:L:" + key)) { returns.SetValue(PlayerPrefsPlus.GetColour32("PlayerPrefsArray:Colour32:" + key + i.ToString()), i); ++i; } return(returns); }
//Get an array of bools public static bool[] GetBoolArray(string key) { bool[] returns = new bool[PlayerPrefs.GetInt("PlayerPrefsArray:Bool:L:" + key)]; int i = 0; while (i < PlayerPrefs.GetInt("PlayerPrefsArray:Bool:L:" + key)) { returns.SetValue(PlayerPrefsPlus.GetBool("PlayerPrefsArray:Bool:" + key + i.ToString()), i); ++i; } return(returns); }
//Get an array of Rects public static Rect[] GetRectArray(string key) { Rect[] returns = new Rect[PlayerPrefs.GetInt("PlayerPrefsArray:Rect:L:" + key)]; int i = 0; while (i < PlayerPrefs.GetInt("PlayerPrefsArray:Rect:L:" + key)) { returns.SetValue(PlayerPrefsPlus.GetRect("PlayerPrefsArray:Rect:" + key + i.ToString()), i); ++i; } return(returns); }
void Awake() { if (kill_string != "" && PlayerPrefsPlus.GetBool(kill_string, false)) { Destroy(gameObject); } if (deathEffect == null) { deathEffect = GameObject.FindGameObjectWithTag("MDP"); } if (healthDrop == null) { healthDrop = GameObject.FindGameObjectWithTag("health_pickup"); } }
// Interacting with items or objects public void OnTriggerEnter(Collider other) { if (gameObject.GetComponent <Health>().Dead) { return; } string tag = other.gameObject.tag; switch (tag) { case "HammerPickup": hasHammer = true; SwitchWeapon(); audio.PlayOneShot(important_pickup); PlayerPrefs.SetInt("hammerPickup", -1); Destroy(other.gameObject); break; case "SwordHilt": PlayerPrefs.SetInt("hiltPickup", -1); audio.PlayOneShot(important_pickup); GameObject.Find("Menu Screens").GetComponent <PauseMenu>().CollectPiece(); other.gameObject.SendMessage("EnableLadderLighting"); Destroy(other.gameObject); break; case "TreasureChest": other.gameObject.SendMessage("OpenChest"); break; case "health_pickup": gameObject.SendMessage("Heal"); Destroy(other.gameObject); break; case "extra_heart": audio.PlayOneShot(important_pickup); particle.Play(); gameObject.SendMessage("IncreaseMaxHealth"); PlayerPrefsPlus.SetBool(other.gameObject.name, true); Destroy(other.gameObject); break; } }
void Start() { //Check block and enable strings if (blockString != "" && PlayerPrefsPlus.GetBool(blockString, false)) { Debug.Log("Block string found"); collider.enabled = false; blocked = true; return; } if (enableString != "" && !PlayerPrefsPlus.GetBool(enableString, false)) { Debug.Log("Enable string not found"); collider.enabled = false; blocked = true; return; } //If kill enemies boolean is true, you have to kill the target enemies to use this trigger if (killEnemies) { collider.enabled = false; } }
public void ToogleMusicNGUI() { PlayerPrefsPlus.SetBool("MUSIC", toggMusic.value); AudioManager.Instance.bgMusic.mute = toggMusic.value; }
// Use this for initialization void Awake() { Instance = this; bgMusic.mute = PlayerPrefsPlus.GetBool("MUSIC"); }
public void LoadNetworkCache(out string address, out int port) { address = PlayerPrefsPlus.GetString(NETWORK_ADDRESS, string.Empty); port = PlayerPrefsPlus.GetInt(NETWORK_PORT, 0); }
public void SaveNetworkCache(string address, int port) { PlayerPrefsPlus.SetString(NETWORK_ADDRESS, address); PlayerPrefsPlus.SetInt(NETWORK_PORT, port); }
void OnGUI() { //Here we're just displaying all the values returned. GUILayout.Label("Boolean: " + boolean.ToString()); GUILayout.Label("Colour: " + colour.ToString()); GUILayout.Label("Colour32: " + colour32.ToString()); GUILayout.Label("Vector2: " + v2.ToString()); GUILayout.Label("Vector3: " + v3.ToString()); GUILayout.Label("Vector4: " + v4.ToString()); GUILayout.Label("Quaternion: " + quat.ToString() + " (Euler: " + quat.eulerAngles.ToString() + ")"); GUILayout.Label("Rect: " + rect.ToString()); //This messes things up if (GUILayout.Button("Mess everything up!")) { if (Random.Range(0, 1) == 1) { boolean = true; } else { boolean = false; } colour = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f)); colour32 = new Color(Random.Range(0, 255), Random.Range(0, 255), Random.Range(0, 255), Random.Range(0, 255)); v2 = new Vector2(Random.Range(-50, 50), Random.Range(-50, 50)); v3 = new Vector3(Random.Range(-50, 50), Random.Range(-50, 50), Random.Range(-50, 50)); v4 = new Vector4(Random.Range(-50, 50), Random.Range(-50, 50), Random.Range(-50, 50), Random.Range(-50, 50)); quat = new Quaternion(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f)); rect = new Rect(Random.Range(0, 50), Random.Range(0, 50), Random.Range(0, 50), Random.Range(0, 50)); } //This restore the values from the save if (GUILayout.Button("Restore from save!")) { boolean = PlayerPrefsPlus.GetBool("TestBool"); colour = PlayerPrefsPlus.GetColour("TestColour"); colour32 = PlayerPrefsPlus.GetColour("TestColour32"); v2 = PlayerPrefsPlus.GetVector2("TestVector2"); v3 = PlayerPrefsPlus.GetVector3("TestVector3"); v4 = PlayerPrefsPlus.GetVector4("TestVector4"); quat = PlayerPrefsPlus.GetQuaternion("TestQuaternion"); rect = PlayerPrefsPlus.GetRect("TestRect"); } //This section will save the values if (GUILayout.Button("Save!")) { PlayerPrefsPlus.SetString("TestString", "hi"); PlayerPrefsPlus.SetInt("TestInt", 0); PlayerPrefsPlus.SetFloat("TestFloat", 0f); PlayerPrefsPlus.SetBool("TestBool", boolean); PlayerPrefsPlus.SetColour("TestColour", colour); PlayerPrefsPlus.SetColour("TestColour32", colour32); PlayerPrefsPlus.SetVector2("TestVector2", v2); PlayerPrefsPlus.SetVector3("TestVector3", v3); PlayerPrefsPlus.SetVector4("TestVector4", v4); PlayerPrefsPlus.SetQuaternion("TestQuaternion", quat); PlayerPrefsPlus.SetRect("TestRect", rect); } GUILayout.Label("Type to see if key exists:"); hasKey = GUILayout.TextField(hasKey); GUILayout.Label(PlayerPrefsPlus.HasKey(hasKey).ToString()); }
// Use this for initialization void Start() { instance = this; toggMusic = GetComponent <UIToggle>(); toggMusic.value = PlayerPrefsPlus.GetBool("MUSIC"); }