void ReInitializePresetsBrowser() { SavePresets(); colorPages = new List <ColorPage>(); savedPresets = PlayerPrefsX.GetColorArray(COLOR_PRESETS_KEY); if (savedPresets == null || savedPresets.Length == 0) { savedPresets = defaultColors; } int pagesCount = Mathf.CeilToInt((float)savedPresets.Length / (float)presetsDisplay.Length); int presetIndex = 0; int remainingPresetsCount = savedPresets.Length; for (int i = 0; i < pagesCount; i++) { var cp = new ColorPage() { ContainsSelectedColor = false, PageColors = new List <Color>() }; int j = 0; while (presetIndex < savedPresets.Length && j < presetsDisplay.Length) { cp.PageColors.Add(savedPresets[presetIndex]); presetIndex++; j++; } colorPages.Add(cp); } }
/// <summary> /// Get list color from ArrayPrefs. /// </summary> /// <param name="t"></param> /// <returns></returns> public List <Color> GetColorList(PlayerPrefsKeys t) { Color[] arr = PlayerPrefsX.GetColorArray(t.ToString( )); List <Color> list = new List <Color>(); list.AddRange(arr); return(list); }
// Use this for initialization void Start() { ResetColorsButton = false; colors = PlayerPrefsX.GetColorArray(colorsKey); times = PlayerPrefsX.GetFloatArray(timeKey); currentDay = PlayerPrefs.GetInt(currentDayKey); if (!cam) { cam = FindObjectOfType <Camera>(); } if (colors.Length < 1 || times.Length < 1) { Debug.Log("Initializing Colors!"); colors = new Color[365]; times = new float[365]; for (int i = 0; i < 365; i++) { colors[i] = new Color(1, 1, 1); times[i] = 0; } currentDay = 0; PlayerPrefsX.SetColorArray(colorsKey, colors); PlayerPrefsX.SetFloatArray(timeKey, times); PlayerPrefs.SetInt(currentDayKey, 0); } //printColors(); //visController.enabled = false; //printColors(); //float bonus = 0.1f; //float RMin = 0.7f + bonus; //float RMax = 0.9f + bonus; //float GMin = 0.32f + bonus; //float GMax = 0.6f + bonus; //float BMin = 0.0f + bonus; //float BMax = 0.39f + bonus; //for (int j = 0; j < colors.Length; j++) //{ // if (j % 2 == 0) // colors[j] = new Color(Random.Range(RMin, RMax), Random.Range(GMin, GMax), Random.Range(BMin, BMax), 1); // else // colors[j] = new Color(Random.Range(1 - RMin, 1 - RMax), Random.Range(1 - GMin, 1 - GMax), Random.Range(1 - BMin, 1 - BMax), 1); //} //for (int i = 0; i < times.Length; i++) //{ // times[i] = Random.Range(240, 375); //} }
private Color setTeamColourUI(int playerNum) { // If any exceptions happen, it will return 0,0,0,0 for the rgba values. //change current team colour ui try { Color[] c = PlayerPrefsX.GetColorArray("PlayerColors"); return(c[playerNum]); } catch { return(new Color(0, 0, 0, 0)); } }
/// <summary> /// Get data in ArrayPrefs for delete. /// </summary> /// <param name="playerPrefsKey"></param> /// <param name="type"></param> /// <param name="color"></param> /// <param name="index"></param> private void Del_Filter(string playerPrefsKey, KeyType type, ColorType color, int index) { if (type == KeyType.INT && color == ColorType.NULL) { int[] arr = PlayerPrefsX.GetIntArray(playerPrefsKey); Del(playerPrefsKey, arr, index); } else if (type == KeyType.STRING && color == ColorType.NULL) { string[] arr = PlayerPrefsX.GetStringArray(playerPrefsKey); Del(playerPrefsKey, arr, index); } else if (type == KeyType.VECTOR3 && color == ColorType.NULL) { Vector3[] arr = PlayerPrefsX.GetVector3Array(playerPrefsKey); Del(playerPrefsKey, arr, index); } else if (type == KeyType.COLOR && color != ColorType.NULL) { Color[] arr = PlayerPrefsX.GetColorArray(playerPrefsKey); Del(playerPrefsKey, arr, color, index); } }
// Load the color array and the currentDay value to the Player Prefs public void loadSettings() { currentDay = PlayerPrefs.GetInt(currentDayKey, 0); times = PlayerPrefsX.GetFloatArray(timeKey); colors = PlayerPrefsX.GetColorArray(colorsKey); }