private static void DrawGradientSwatchInternal(Rect position, Gradient gradient, SerializedProperty property, Color bgColor)
{
if (Event.current.type == EventType.Repaint)
{
Texture2D backgroundTexture = GetBackgroundTexture();
if (backgroundTexture != null)
{
Color color = GUI.color;
GUI.color = bgColor;
EditorGUIUtility.GetBasicTextureStyle(backgroundTexture).Draw(position, false, false, false, false);
GUI.color = color;
}
Texture2D tex = null;
if (property != null)
{
tex = GradientPreviewCache.GetPropertyPreview(property);
}
else
{
tex = GradientPreviewCache.GetGradientPreview(gradient);
}
if (tex == null)
{
Debug.Log("Warning: Could not create preview for gradient");
}
else
{
EditorGUIUtility.GetBasicTextureStyle(tex).Draw(position, false, false, false, false);
}
}
}