public static Color GetColor(string key, Color fallback)
 {
     if (s_Preferences != null && preferences.HasKey <Color>(key))
     {
         return(preferences.GetColor(key, fallback));
     }
     InternalUtility.TryParseColor(EditorPrefs.GetString(key), ref fallback);
     return(fallback);
 }
Пример #2
0
        /// <summary>
        /// Older versions of probuilder stored a fixed size array of colors in EditorPrefs. Use this function to get a
        /// pb_ColorPalette from the older version.
        /// </summary>
        /// <returns>
        /// </returns>
        static void CopyColorsFromEditorPrefs(ColorPalette target)
        {
            List <Color> colors = new List <Color>();

            for (int i = 0; i < k_EditorPrefsColorPaletteCount; i++)
            {
                Color color = Color.white;

                if (InternalUtility.TryParseColor(EditorPrefs.GetString(pbVertexColorPrefs + i), ref color))
                {
                    colors.Add(color);
                }
            }

            if (colors.Count > 0)
            {
                target.SetColors(colors);
                UnityEditor.EditorUtility.SetDirty(target);
            }
        }