public static bool TryGetColor(bool allowHDR, out Color color) { bool flag = false; if (ColorUtility.TryParseHtmlString(EditorGUIUtility.systemCopyBuffer, out color)) flag = true; else if (EditorGUIUtility.HasPasteboardColor()) { color = EditorGUIUtility.GetPasteboardColor(); flag = true; } if (!flag) return false; if (!allowHDR && (double) color.maxColorComponent > 1.0) color = color.RGBMultiplied(1f / color.maxColorComponent); return true; }
private void SetColor(Color c) { if (this.m_IsOSColorPicker) { OSColorPicker.color = c; } else { float hdrScaleFactor = this.m_HDRValues.m_HDRScaleFactor; if (this.m_HDR) { float maxColorComponent = c.maxColorComponent; if ((double) maxColorComponent > 1.0) c = c.RGBMultiplied(1f / maxColorComponent); this.SetHDRScaleFactor(Mathf.Max(1f, maxColorComponent)); } if ((double) this.m_Color.r == (double) c.r && (double) this.m_Color.g == (double) c.g && ((double) this.m_Color.b == (double) c.b && (double) this.m_Color.a == (double) c.a) && (double) hdrScaleFactor == (double) this.m_HDRValues.m_HDRScaleFactor) return; if ((double) c.r > 1.0 || (double) c.g > 1.0 || (double) c.b > 1.0) Debug.LogError((object) string.Format("Invalid normalized color: {0}, normalize value: {1}", (object) c, (object) this.m_HDRValues.m_HDRScaleFactor)); this.m_resetKeyboardControl = true; this.SetNormalizedColor(c); this.Repaint(); } }
private void DrawInternal(Rect rect, Color preset) { this.Init(); bool flag = preset.maxColorComponent > 1f; if (flag) { preset = preset.RGBMultiplied((float) (1f / preset.maxColorComponent)); } Color color = GUI.color; if (((int) rect.height) == 14) { if (preset.a > 0.97f) { this.RenderSolidSwatch(rect, preset); } else { this.RenderSwatchWithAlpha(rect, preset, this.m_ColorSwatchTriangular); } if (flag) { GUI.Label(rect, "h"); } } else { this.RenderSwatchWithAlpha(rect, preset, this.m_MiniColorSwatchTriangular); } GUI.color = color; }
internal static Color DoHexColorTextField(Rect rect, Color color, bool showAlpha, GUIStyle style) { bool flag = false; if ((double) color.maxColorComponent > 1.0) { color = color.RGBMultiplied(1f / color.maxColorComponent); flag = true; } Rect position = new Rect(rect.x, rect.y, 14f, rect.height); rect.xMin += 14f; GUI.Label(position, GUIContent.Temp("#")); string text = !showAlpha ? ColorUtility.ToHtmlStringRGB(color) : ColorUtility.ToHtmlStringRGBA(color); EditorGUI.BeginChangeCheck(); int controlId = GUIUtility.GetControlID(EditorGUI.s_TextFieldHash, FocusType.Keyboard, rect); bool changed; string str = EditorGUI.DoTextField(EditorGUI.s_RecycledEditor, controlId, rect, text, style, "0123456789ABCDEFabcdef", out changed, false, false, false); if (EditorGUI.EndChangeCheck()) { EditorGUI.s_RecycledEditor.text = EditorGUI.s_RecycledEditor.text.ToUpper(); Color color1; if (ColorUtility.TryParseHtmlString("#" + str, out color1)) color = new Color(color1.r, color1.g, color1.b, !showAlpha ? color.a : color1.a); } if (flag) { EditorGUIUtility.SetIconSize(new Vector2(16f, 16f)); GUI.Label(new Rect(position.x - 20f, rect.y, 20f, 20f), EditorGUI.s_HDRWarning); EditorGUIUtility.SetIconSize(Vector2.zero); } return color; }
private void SetColor(Color c) { if (this.m_IsOSColorPicker) { OSColorPicker.color = c; } else { float hDRScaleFactor = this.m_HDRValues.m_HDRScaleFactor; if (this.m_HDR) { float maxColorComponent = c.maxColorComponent; if (maxColorComponent > 1f) { c = c.RGBMultiplied((float) (1f / maxColorComponent)); } this.SetHDRScaleFactor(Mathf.Max(1f, maxColorComponent)); } if ((((this.m_Color.r != c.r) || (this.m_Color.g != c.g)) || ((this.m_Color.b != c.b) || (this.m_Color.a != c.a))) || (hDRScaleFactor != this.m_HDRValues.m_HDRScaleFactor)) { if (((c.r > 1f) || (c.g > 1f)) || (c.b > 1f)) { Debug.LogError(string.Format("Invalid normalized color: {0}, normalize value: {1}", c, this.m_HDRValues.m_HDRScaleFactor)); } this.m_resetKeyboardControl = true; this.SetNormalizedColor(c); base.Repaint(); } } }
private void DrawInternal(Rect rect, Color preset) { this.Init(); bool flag = (double) preset.maxColorComponent > 1.0; if (flag) preset = preset.RGBMultiplied(1f / preset.maxColorComponent); Color color = GUI.color; if ((int) rect.height == 14) { if ((double) preset.a > 0.970000028610229) this.RenderSolidSwatch(rect, preset); else this.RenderSwatchWithAlpha(rect, preset, this.m_ColorSwatchTriangular); if (flag) GUI.Label(rect, "h"); } else this.RenderSwatchWithAlpha(rect, preset, this.m_MiniColorSwatchTriangular); GUI.color = color; }