UnityEditor.GradientEditor.DrawGradientWithBackground C# (CSharp) Method

DrawGradientWithBackground() public static method

public static DrawGradientWithBackground ( Rect position, Texture2D gradientTexture ) : void
position UnityEngine.Rect
gradientTexture UnityEngine.Texture2D
return void
        public static void DrawGradientWithBackground(Rect position, Texture2D gradientTexture)
        {
            Rect rect = new Rect(position.x + 1f, position.y + 1f, position.width - 2f, position.height - 2f);
            Texture2D backgroundTexture = GetBackgroundTexture();
            Rect texCoords = new Rect(0f, 0f, rect.width / ((float) backgroundTexture.width), rect.height / ((float) backgroundTexture.height));
            GUI.DrawTextureWithTexCoords(rect, backgroundTexture, texCoords, false);
            if (gradientTexture != null)
            {
                GUI.DrawTexture(rect, gradientTexture, ScaleMode.StretchToFill, true);
            }
            GUI.Label(position, GUIContent.none, EditorStyles.colorPickerBox);
        }

Usage Example

 private void DrawInternal(Rect rect, Gradient gradient)
 {
     if (gradient != null)
     {
         GradientEditor.DrawGradientWithBackground(rect, GradientPreviewCache.GetGradientPreview(gradient));
     }
 }
All Usage Examples Of UnityEditor.GradientEditor::DrawGradientWithBackground