GetBackgroundTexture() public static method

public static GetBackgroundTexture ( ) : Texture2D
return UnityEngine.Texture2D
Beispiel #1
0
        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);
        }
        private static void DrawGradientSwatchInternal(Rect position, Gradient gradient, SerializedProperty property, Color bgColor)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            Texture2D backgroundTexture = GradientEditor.GetBackgroundTexture();

            if ((UnityEngine.Object)backgroundTexture != (UnityEngine.Object)null)
            {
                Color color = GUI.color;
                GUI.color = bgColor;
                EditorGUIUtility.GetBasicTextureStyle(backgroundTexture).Draw(position, false, false, false, false);
                GUI.color = color;
            }
            Texture2D tex = property == null?GradientPreviewCache.GetGradientPreview(gradient) : GradientPreviewCache.GetPropertyPreview(property);

            if ((UnityEngine.Object)tex == (UnityEngine.Object)null)
            {
                Debug.Log((object)"Warning: Could not create preview for gradient");
            }
            else
            {
                EditorGUIUtility.GetBasicTextureStyle(tex).Draw(position, false, false, false, false);
            }
        }
Beispiel #3
0
 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);
                 }
             }
         }
     }
 }
Beispiel #4
0
        public static void DrawGradientWithBackground(Rect position, Texture2D gradientTexture)
        {
            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 (gradientTexture != null)
            {
                GUI.DrawTexture(position2, gradientTexture, ScaleMode.StretchToFill, true);
            }
            GUI.Label(position, GUIContent.none, EditorStyles.colorPickerBox);
        }
Beispiel #5
0
        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);
            }
        }
Beispiel #6
0
        private static void DrawGradientSwatchInternal(Rect position, Gradient gradient, SerializedProperty property, Color bgColor, ColorSpace colorSpace)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (EditorGUI.showMixedValue)
            {
                Color oldColor = GUI.color;
                float a        = GUI.enabled ? 1 : 2;

                GUI.color = new Color(0.82f, 0.82f, 0.82f, a) * bgColor;
                GUIStyle mgs = EditorGUIUtility.whiteTextureStyle;
                mgs.Draw(position, false, false, false, false);

                EditorGUI.BeginHandleMixedValueContentColor();
                mgs.Draw(position, EditorGUI.mixedValueContent, false, false, false, false);
                EditorGUI.EndHandleMixedValueContentColor();

                GUI.color = oldColor;
                return;
            }

            // Draw Background
            Texture2D backgroundTexture = GradientEditor.GetBackgroundTexture();

            if (backgroundTexture != null)
            {
                Color oldColor = GUI.color;
                GUI.color = bgColor;

                GUIStyle backgroundStyle = EditorGUIUtility.GetBasicTextureStyle(backgroundTexture);
                backgroundStyle.Draw(position, false, false, false, false);

                GUI.color = oldColor;
            }

            // DrawTexture
            Texture2D preview = null;
            float     maxColorComponent;

            bool linearGradientKeys = colorSpace == ColorSpace.Linear;

            if (colorSpace == ColorSpace.Uninitialized)
            {
                Debug.LogError("GradientEditor color space is not initialized, assuming linear gradient keys to build the gradient preview.");
                linearGradientKeys = true;
            }
            if (property != null)
            {
                preview           = GradientPreviewCache.GetPropertyPreview(property, linearGradientKeys);
                maxColorComponent = GetMaxColorComponent(property.gradientValue);
            }
            else
            {
                preview           = GradientPreviewCache.GetGradientPreview(gradient, linearGradientKeys);
                maxColorComponent = GetMaxColorComponent(gradient);
            }

            if (preview == null)
            {
                Debug.Log("Warning: Could not create preview for gradient");
                return;
            }

            Color color = GUI.color;

            GUI.color = Color.white;            //Dont want the Playmode tint to be applied to gradient textures.
            GUIStyle gs = EditorGUIUtility.GetBasicTextureStyle(preview);

            gs.Draw(position, false, false, false, false);
            GUI.color = color;

            // HDR label
            if (maxColorComponent > 1.0f)
            {
                GUI.Label(new Rect(position.x, position.y - 1, position.width - 3, position.height + 2), "HDR", EditorStyles.centeredGreyMiniLabel);
            }
        }
Beispiel #7
0
        private static void DrawGradientSwatchInternal(Rect position, Gradient gradient, SerializedProperty property, Color bgColor)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (EditorGUI.showMixedValue)
            {
                Color oldColor = GUI.color;
                float a        = GUI.enabled ? 1 : 2;

                GUI.color = new Color(0.82f, 0.82f, 0.82f, a) * bgColor;
                GUIStyle mgs = EditorGUIUtility.whiteTextureStyle;
                mgs.Draw(position, false, false, false, false);

                EditorGUI.BeginHandleMixedValueContentColor();
                mgs.Draw(position, EditorGUI.mixedValueContent, false, false, false, false);
                EditorGUI.EndHandleMixedValueContentColor();

                GUI.color = oldColor;
                return;
            }

            // Draw Background
            Texture2D backgroundTexture = GradientEditor.GetBackgroundTexture();

            if (backgroundTexture != null)
            {
                Color oldColor = GUI.color;
                GUI.color = bgColor;

                GUIStyle backgroundStyle = EditorGUIUtility.GetBasicTextureStyle(backgroundTexture);
                backgroundStyle.Draw(position, false, false, false, false);

                GUI.color = oldColor;
            }

            // DrawTexture
            Texture2D preview = null;
            float     maxColorComponent;

            if (property != null)
            {
                preview           = GradientPreviewCache.GetPropertyPreview(property);
                maxColorComponent = GetMaxColorComponent(property.gradientValue);
            }
            else
            {
                preview           = GradientPreviewCache.GetGradientPreview(gradient);
                maxColorComponent = GetMaxColorComponent(gradient);
            }

            if (preview == null)
            {
                Debug.Log("Warning: Could not create preview for gradient");
                return;
            }

            GUIStyle gs = EditorGUIUtility.GetBasicTextureStyle(preview);

            gs.Draw(position, false, false, false, false);

            // HDR label
            if (maxColorComponent > 1.0f)
            {
                GUI.Label(new Rect(position.x, position.y - 1, position.width - 3, position.height + 2), "HDR", EditorStyles.centeredGreyMiniLabel);
            }
        }