public void SetColor(ProjectColor newColor, bool save = true) { if (newColor == null || newColor.id == 0) { if (color == null || color.id == 0) { return; } } else { if ((color != null) && (newColor.id == color.id)) { return; } } color = newColor; if (color == null || color.id == 0) { color_id = 0; } else { color_id = color.id; } if (save) { Update(); } }
public ProjectColor FormColorField(ProjectColor selected, int width = 400) { GUIStyle style; if (selected == null || selected.id == 0) { style = new GUIStyle(EditorStyles.label); } else { style = new GUIStyle(); } style.clipping = TextClipping.Clip; style.alignment = TextAnchor.MiddleLeft; style.padding = new RectOffset(10, 10, 2, 2); // left, right, top, bottom if (selected == null || selected.id == 0) { style.normal.textColor = Color.white; style.focused.textColor = Color.white; } else { style.normal.background = Colors.MakeTexture( width, 1, // height selected.GetColor() ); style.normal.textColor = selected.GetTextColor(); } return(Project.GetColorById( EditorGUILayout.IntPopup( (selected == null || selected.id == 0) ? 0 : selected.id, Project.GetColorDisplayedOptions(), Project.GetColorOptionValues(), style, GUILayout.Width(width) ) )); }