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