UnityEditor.MaterialEditor.TexturePropertyWithHDRColor C# (CSharp) Method

TexturePropertyWithHDRColor() public method

public TexturePropertyWithHDRColor ( GUIContent label, MaterialProperty textureProp, MaterialProperty colorProperty, ColorPickerHDRConfig hdrConfig, bool showAlpha ) : Rect
label UnityEngine.GUIContent
textureProp MaterialProperty
colorProperty MaterialProperty
hdrConfig ColorPickerHDRConfig
showAlpha bool
return UnityEngine.Rect
        public Rect TexturePropertyWithHDRColor(GUIContent label, MaterialProperty textureProp, MaterialProperty colorProperty, ColorPickerHDRConfig hdrConfig, bool showAlpha)
        {
            ColorPickerHDRConfig defaultHDRConfig;
            Rect controlRectForSingleLine = this.GetControlRectForSingleLine();
            this.TexturePropertyMiniThumbnail(controlRectForSingleLine, textureProp, label.text, label.tooltip);
            if (colorProperty.type != MaterialProperty.PropType.Color)
            {
                Debug.LogError("Assuming MaterialProperty.PropType.Color (was " + colorProperty.type + ")");
                return controlRectForSingleLine;
            }
            this.BeginAnimatedCheck(colorProperty);
            if (hdrConfig != null)
            {
                defaultHDRConfig = hdrConfig;
            }
            else
            {
                defaultHDRConfig = ColorPicker.defaultHDRConfig;
            }
            Rect leftAlignedFieldRect = GetLeftAlignedFieldRect(controlRectForSingleLine);
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = colorProperty.hasMixedValue;
            Color color = EditorGUI.ColorField(leftAlignedFieldRect, GUIContent.none, colorProperty.colorValue, true, showAlpha, true, defaultHDRConfig);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                colorProperty.colorValue = color;
            }
            Rect flexibleRectBetweenFieldAndRightEdge = GetFlexibleRectBetweenFieldAndRightEdge(controlRectForSingleLine);
            float labelWidth = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth = flexibleRectBetweenFieldAndRightEdge.width - EditorGUIUtility.fieldWidth;
            EditorGUI.BeginChangeCheck();
            color = EditorGUI.ColorBrightnessField(flexibleRectBetweenFieldAndRightEdge, GUIContent.Temp(" "), colorProperty.colorValue, defaultHDRConfig.minBrightness, defaultHDRConfig.maxBrightness);
            if (EditorGUI.EndChangeCheck())
            {
                colorProperty.colorValue = color;
            }
            EditorGUIUtility.labelWidth = labelWidth;
            this.EndAnimatedCheck();
            return controlRectForSingleLine;
        }

Usage Example

        void DoEmissionArea(Material material)
        {
            // Emission for GI?
            if (m_MaterialEditor.EmissionEnabledProperty())
            {
                bool hadEmissionTexture = emissionMap.textureValue != null;

                // Texture and HDR color controls
        #if UNITY_2018_1_OR_NEWER
                m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false);
        #else
                m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false);
        #endif

                // If texture was assigned and color was black set color to white
                float brightness = emissionColorForRendering.colorValue.maxColorComponent;
                if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f)
                {
                    emissionColorForRendering.colorValue = Color.white;
                }

                // change the GI flag and fix it up with emissive as black if necessary
                m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true);
            }
        }
All Usage Examples Of UnityEditor.MaterialEditor::TexturePropertyWithHDRColor
MaterialEditor