private static void DrawGradientSwatchInternal(Rect position, Gradient gradient, SerializedProperty property, Color bgColor) { if (Event.current.type == EventType.Repaint) { if (EditorGUI.showMixedValue) { Color color = GUI.color; float a = (float)((!GUI.enabled) ? 2 : 1); GUI.color = new Color(0.82f, 0.82f, 0.82f, a) * bgColor; GUIStyle whiteTextureStyle = EditorGUIUtility.whiteTextureStyle; whiteTextureStyle.Draw(position, false, false, false, false); EditorGUI.BeginHandleMixedValueContentColor(); whiteTextureStyle.Draw(position, EditorGUI.mixedValueContent, false, false, false, false); EditorGUI.EndHandleMixedValueContentColor(); GUI.color = color; } else { Texture2D backgroundTexture = GradientEditor.GetBackgroundTexture(); if (backgroundTexture != null) { Color color2 = GUI.color; GUI.color = bgColor; GUIStyle basicTextureStyle = EditorGUIUtility.GetBasicTextureStyle(backgroundTexture); basicTextureStyle.Draw(position, false, false, false, false); GUI.color = color2; } Texture2D texture2D; float maxColorComponent; if (property != null) { texture2D = GradientPreviewCache.GetPropertyPreview(property); maxColorComponent = GradientEditor.GetMaxColorComponent(property.gradientValue); } else { texture2D = GradientPreviewCache.GetGradientPreview(gradient); maxColorComponent = GradientEditor.GetMaxColorComponent(gradient); } if (texture2D == null) { Debug.Log("Warning: Could not create preview for gradient"); } else { GUIStyle basicTextureStyle2 = EditorGUIUtility.GetBasicTextureStyle(texture2D); basicTextureStyle2.Draw(position, false, false, false, false); if (maxColorComponent > 1f) { GUI.Label(new Rect(position.x, position.y - 1f, position.width - 3f, position.height + 2f), "HDR", EditorStyles.centeredGreyMiniLabel); } } } } }
public static void DrawGradientWithBackground(Rect position, Gradient gradient) { Texture2D gradientPreview = GradientPreviewCache.GetGradientPreview(gradient); Rect position2 = new Rect(position.x + 1f, position.y + 1f, position.width - 2f, position.height - 2f); Texture2D backgroundTexture = GradientEditor.GetBackgroundTexture(); Rect texCoords = new Rect(0f, 0f, position2.width / (float)backgroundTexture.width, position2.height / (float)backgroundTexture.height); GUI.DrawTextureWithTexCoords(position2, backgroundTexture, texCoords, false); if (gradientPreview != null) { GUI.DrawTexture(position2, gradientPreview, ScaleMode.StretchToFill, true); } GUI.Label(position, GUIContent.none, EditorStyles.colorPickerBox); float maxColorComponent = GradientEditor.GetMaxColorComponent(gradient); if (maxColorComponent > 1f) { GUI.Label(new Rect(position.x, position.y, position.width - 3f, position.height), "HDR", EditorStyles.centeredGreyMiniLabel); } }