Esempio n. 1
0
        /// <summary> Delete all prefs </summary>
        public static void ResetPrefs()
        {
            if (EditorPrefs.HasKey("xNode.Settings"))
            {
                EditorPrefs.DeleteKey("xNode.Settings");
            }

            settings      = LoadPrefs();
            typeColors    = new Dictionary <string, Color>();
            _gridTexture  = NodeEditorResources.GenerateGridTexture(settings.gridLineColor, settings.gridBgColor);
            _crossTexture = NodeEditorResources.GenerateCrossTexture(settings.gridLineColor);
            NodeEditorWindow.RepaintAll();
        }
Esempio n. 2
0
        private static void GridSettingsGUI()
        {
            //Label
            EditorGUILayout.LabelField("Grid", EditorStyles.boldLabel);
            settings.gridSnap = EditorGUILayout.Toggle("Snap", settings.gridSnap);

            settings.gridLineColor = EditorGUILayout.ColorField("Color", settings.gridLineColor);
            settings.gridBgColor   = EditorGUILayout.ColorField(" ", settings.gridBgColor);
            if (GUI.changed)
            {
                SavePrefs();
                _gridTexture  = NodeEditorResources.GenerateGridTexture(settings.gridLineColor, settings.gridBgColor);
                _crossTexture = NodeEditorResources.GenerateCrossTexture(settings.gridLineColor);
                NodeEditorWindow.RepaintAll();
            }
            EditorGUILayout.Space();
        }
Esempio n. 3
0
        private static void LoadPrefs()
        {
            //Load type colors
            generatedTypeColors = new Dictionary <string, Color>();

            if (!EditorPrefs.HasKey("unec_typecolors"))
            {
                EditorPrefs.SetString("unec_typecolors", "");
            }
            string[] data = EditorPrefs.GetString("unec_typecolors").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            typeColors = new Dictionary <string, Color>();
            for (int i = 0; i < data.Length; i += 2)
            {
                Color col;
                if (ColorUtility.TryParseHtmlString("#" + data[i + 1], out col))
                {
                    typeColors.Add(data[i], col);
                }
            }

            //Load grid colors
            if (!EditorPrefs.HasKey("unec_gridcolor0"))
            {
                EditorPrefs.SetString("unec_gridcolor0", ColorUtility.ToHtmlStringRGB(new Color(0.45f, 0.45f, 0.45f)));
            }
            ColorUtility.TryParseHtmlString("#" + EditorPrefs.GetString("unec_gridcolor0"), out _gridLineColor);
            if (!EditorPrefs.HasKey("unec_gridcolor1"))
            {
                EditorPrefs.SetString("unec_gridcolor1", ColorUtility.ToHtmlStringRGB(new Color(0.18f, 0.18f, 0.18f)));
            }
            ColorUtility.TryParseHtmlString("#" + EditorPrefs.GetString("unec_gridcolor1"), out _gridBgColor);

            //Load snap option
            if (EditorPrefs.HasKey("unec_gridsnap"))
            {
                _gridSnap = EditorPrefs.GetBool("unec_gridsnap");
            }

            _gridTexture  = NodeEditorResources.GenerateGridTexture(_gridLineColor, _gridBgColor);
            _crossTexture = NodeEditorResources.GenerateCrossTexture(_gridLineColor);
            NodeEditorWindow.RepaintAll();
            prefsLoaded = true;
        }