Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

Help with Playerprefs to saving colors of buttons.

$
0
0
I am trying to save my colors of 12 different buttons with using Playerprefs, but for some reason the script is not working. ---------- When I exit the play mode and restart the play mode in Unity, the buttons revert back to their original colors and not the new selected colors. ---------- This is the code that I am currently using using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SaveLoadColors : MonoBehaviour { public static void SaveColor (Color color, string key) { string col = color.ToString (); col = col.Replace ("RGBA)", ""); col = col.Replace (")", ""); PlayerPrefs.SetString (key, col); } public static Color GetSaveColor (string key) { string col = PlayerPrefs.GetString (key); Debug.Log (col); if (col == "") { return Color.white; } string[] strings = col.Split (','); Color output = new Color (); for (int i = 0; i < 4; i++) { output [i] = System.Single.Parse (strings [i]); } return output; }

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>