UnityEditor.GradientEditor.DrawGradientSwatchInternal C# (CSharp) Method

DrawGradientSwatchInternal() private static method

private static DrawGradientSwatchInternal ( Rect position, Gradient gradient, UnityEditor.SerializedProperty property, Color bgColor ) : void
position UnityEngine.Rect
gradient UnityEngine.Gradient
property UnityEditor.SerializedProperty
bgColor Color
return void
        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);
                }
            }
        }

Usage Example

示例#1
0
 public static void DrawGradientSwatch(Rect position, Gradient gradient, Color bgColor)
 {
     GradientEditor.DrawGradientSwatchInternal(position, gradient, null, bgColor);
 }
All Usage Examples Of UnityEditor.GradientEditor::DrawGradientSwatchInternal