1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 17:26:02 +08:00

Added color settings for selection outlines

This commit is contained in:
Thor Brigsted 2018-01-25 10:43:03 +01:00
parent 9dc5653f27
commit 14c4d0b691
3 changed files with 18 additions and 5 deletions

View File

@ -46,7 +46,7 @@ namespace XNodeEditor {
if (Selection.objects[i] is XNode.Node) { if (Selection.objects[i] is XNode.Node) {
XNode.Node node = Selection.objects[i] as XNode.Node; XNode.Node node = Selection.objects[i] as XNode.Node;
node.position = WindowToGridPosition(e.mousePosition) + dragOffset[i]; node.position = WindowToGridPosition(e.mousePosition) + dragOffset[i];
if (NodeEditorPreferences.gridSnap) { if (NodeEditorPreferences.GridSnap) {
node.position.x = (Mathf.Round((node.position.x + 8) / 16) * 16) - 8; node.position.x = (Mathf.Round((node.position.x + 8) / 16) * 16) - 8;
node.position.y = (Mathf.Round((node.position.y + 8) / 16) * 16) - 8; node.position.y = (Mathf.Round((node.position.y + 8) / 16) * 16) - 8;
} }

View File

@ -240,7 +240,7 @@ namespace XNodeEditor {
style.padding = new RectOffset(); style.padding = new RectOffset();
GUI.color = nodeEditor.GetTint(); GUI.color = nodeEditor.GetTint();
GUILayout.BeginVertical(new GUIStyle(style)); GUILayout.BeginVertical(new GUIStyle(style));
GUI.color = Color.white; GUI.color = NodeEditorPreferences.HighlightColor;
GUILayout.BeginVertical(new GUIStyle(highlightStyle)); GUILayout.BeginVertical(new GUIStyle(highlightStyle));
} else { } else {
GUIStyle style = NodeEditorResources.styles.nodeBody; GUIStyle style = NodeEditorResources.styles.nodeBody;

View File

@ -23,8 +23,8 @@ namespace XNodeEditor {
} }
private static Texture2D _crossTexture; private static Texture2D _crossTexture;
/// <summary> TypeColors requested by the editor </summary> public static bool GridSnap { get { VerifyLoaded(); return settings.gridSnap; } }
public static bool gridSnap { get { VerifyLoaded(); return settings.gridSnap; } } public static Color HighlightColor { get { VerifyLoaded(); return settings.highlightColor; } }
private static Dictionary<string, Color> typeColors = new Dictionary<string, Color>(); private static Dictionary<string, Color> typeColors = new Dictionary<string, Color>();
private static Settings settings; private static Settings settings;
@ -33,6 +33,7 @@ namespace XNodeEditor {
private class Settings : ISerializationCallbackReceiver { private class Settings : ISerializationCallbackReceiver {
public Color32 gridLineColor = new Color(0.45f, 0.45f, 0.45f); public Color32 gridLineColor = new Color(0.45f, 0.45f, 0.45f);
public Color32 gridBgColor = new Color(0.18f, 0.18f, 0.18f); public Color32 gridBgColor = new Color(0.18f, 0.18f, 0.18f);
public Color32 highlightColor = new Color32(255, 223, 255, 255);
public bool gridSnap = true; public bool gridSnap = true;
public string typeColorsData = ""; public string typeColorsData = "";
public Dictionary<string, Color> typeColors = new Dictionary<string, Color>(); public Dictionary<string, Color> typeColors = new Dictionary<string, Color>();
@ -62,6 +63,7 @@ namespace XNodeEditor {
private static void PreferencesGUI() { private static void PreferencesGUI() {
VerifyLoaded(); VerifyLoaded();
NodeSettingsGUI();
GridSettingsGUI(); GridSettingsGUI();
TypeColorsGUI(); TypeColorsGUI();
if (GUILayout.Button(new GUIContent("Set Default", "Reset all values to default"), GUILayout.Width(120))) { if (GUILayout.Button(new GUIContent("Set Default", "Reset all values to default"), GUILayout.Width(120))) {
@ -85,9 +87,20 @@ namespace XNodeEditor {
EditorGUILayout.Space(); EditorGUILayout.Space();
} }
private static void NodeSettingsGUI() {
//Label
EditorGUILayout.LabelField("Node", EditorStyles.boldLabel);
settings.highlightColor = EditorGUILayout.ColorField("Selection", settings.highlightColor);
if (GUI.changed) {
SavePrefs();
NodeEditorWindow.RepaintAll();
}
EditorGUILayout.Space();
}
private static void TypeColorsGUI() { private static void TypeColorsGUI() {
//Label //Label
EditorGUILayout.LabelField("Type colors", EditorStyles.boldLabel); EditorGUILayout.LabelField("Types", EditorStyles.boldLabel);
//Display type colors. Save them if they are edited by the user //Display type colors. Save them if they are edited by the user
List<string> keys = new List<string>(typeColors.Keys); List<string> keys = new List<string>(typeColors.Keys);