FloatProperty() public method

public FloatProperty ( MaterialProperty prop, string label ) : float
prop MaterialProperty
label string
return float
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                BlendModePopup();

                // Primary properties
                GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);
                DoAlbedoArea(material);
                DoSpecularMetallicArea();
                m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null);
                DoEmissionArea(material);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
                EditorGUI.BeginChangeCheck();
                m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
                if (EditorGUI.EndChangeCheck())
                {
                    emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
                }
                EditorGUILayout.Space();

                // Secondary properties
                GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale);
                m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap);
                m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text);

                EditorGUILayout.Space();

                GUILayout.Label(Styles.XRayMode, EditorStyles.boldLabel);
                m_MaterialEditor.ColorProperty(XRayColor, Styles.XRayColor.text);
                m_MaterialEditor.FloatProperty(XRayFPOW, Styles.XRayFPOW.text);
                m_MaterialEditor.FloatProperty(XRayR0, Styles.XRayR0.text);
                // Third properties
                GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel);
                if (highlights != null)
                {
                    m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText);
                }
                if (reflections != null)
                {
                    m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText);
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in blendMode.targets)
                {
                    MaterialChanged((Material)obj, m_WorkflowMode);
                }
            }
        }
        public void ShaderPropertiesGUI(Material material)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0f;

            // Detect any changes to the material
            EditorGUI.BeginChangeCheck();
            {
                BlendModePopup();

                // Primary properties
                GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);
                DoAlbedoArea(material);
                DoSpecularMetallicArea();
                m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null);
                m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null);
                DoEmissionArea(material);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
                EditorGUI.BeginChangeCheck();
                m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
                if (EditorGUI.EndChangeCheck())
                {
                    emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset;                     // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
                }
                EditorGUILayout.Space();

                // Secondary properties
                GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap);
                m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale);
                m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap);
                m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text);

                EditorGUILayout.Space();

                //terrain blending properties
                m_MaterialEditor.TexturePropertySingleLine(Styles.terrainAlbedoText, terrainalbedo);
                m_MaterialEditor.TexturePropertySingleLine(Styles.terrainBumpText, terrainbump);
                m_MaterialEditor.ColorProperty(colorcorrection, Styles.ColorCorrectionText.text);

                m_MaterialEditor.FloatProperty(terrainglossiness, Styles.terrainGlossinessText.text);
                m_MaterialEditor.FloatProperty(terrainmetallic, Styles.terrainMetallicText.text);
                m_MaterialEditor.FloatProperty(terrainblend, Styles.BlendText.text);
                m_MaterialEditor.FloatProperty(terrainblendoffset, Styles.BlendOffsetText.text);
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in blendMode.targets)
                {
                    MaterialChanged((Material)obj, m_WorkflowMode);
                }
            }
        }
        void DoDissolveArea(Material material)
        {
            m_MaterialEditor.TexturePropertySingleLine(Styles.dissolveMapText, dissolveMap);
            m_MaterialEditor.ShaderProperty(dissolveAmount, Styles.dissolveAmountText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);

            //m_MaterialEditor.TexturePropertySingleLine(Styles.directionMapText, directionMap);
            m_MaterialEditor.TexturePropertySingleLine(Styles.substituteText, substituteMap);

            EditorGUILayout.Space();
            m_MaterialEditor.ShaderProperty(dissolveGlow, Styles.burnInText.text);

            if (material.IsKeywordEnabled("_DISSOLVEGLOW_ON"))
            {
                m_MaterialEditor.ShaderProperty(glowFollow, Styles.glowFollowText.text);
                m_MaterialEditor.ColorProperty(glowColor, Styles.burnColorText.text);
                m_MaterialEditor.FloatProperty(glowIntensity, Styles.burnIntensity.text);
            }

            EditorGUILayout.Space();
            //m_MaterialEditor.ShaderProperty(edgeGlow, Styles.edgeGlowText.text);

            if (!material.IsKeywordEnabled("_EDGECOLORRAMP_USE"))
            {
                m_MaterialEditor.ShaderProperty(colorBlend, Styles.blendColorsText.text);
                m_MaterialEditor.ColorProperty(outerEdgeColor, Styles.outerEdgeText.text);
                if (!material.IsKeywordEnabled("_COLORBLENDING_ON"))
                {
                    m_MaterialEditor.ShaderProperty(outerEdgeThickness, Styles.edgeThicknessText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
                }
                m_MaterialEditor.ColorProperty(innerEdgeColor, Styles.innerEdgeText.text);
                if (!material.IsKeywordEnabled("_COLORBLENDING_ON"))
                {
                    m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
                }
                else
                {
                    m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessSoloText.text);
                }
            }
            else
            {
                m_MaterialEditor.TexturePropertySingleLine(Styles.edgeColorRampText, edgeColorRamp);
                m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessSoloText.text);
            }

            EditorGUILayout.Space();
            EditorGUI.indentLevel++;
            m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, Styles.advancedSettings);
            if (m_AdvancedSettings)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.Space();
                DoAdvancedArea(material);
                EditorGUI.indentLevel--;
            }
            EditorGUI.indentLevel--;
        }
示例#4
0
        void DoEmissionArea(Material material)
        {
            bool showEmissionColorAndGIControls = emissionScaleUI.floatValue > 0f;
            bool hadEmissionTexture             = emissionMap.textureValue != null;

            // Do controls
            m_MaterialEditor.TexturePropertySingleLine(Styles.emissionText, emissionMap, showEmissionColorAndGIControls ? emissionColorUI : null, emissionScaleUI);

            // Set default emissionScaleUI if texture was assigned
            if (emissionMap.textureValue != null && !hadEmissionTexture && emissionScaleUI.floatValue <= 0f)
            {
                emissionScaleUI.floatValue = 1.0f;
            }

            // Dynamic Lightmapping mode
            if (showEmissionColorAndGIControls)
            {
                bool shouldEmissionBeEnabled = ShouldEmissionBeEnabled(EvalFinalEmissionColor(material));
                EditorGUI.BeginDisabledGroup(!shouldEmissionBeEnabled);

                m_MaterialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);

                m_MaterialEditor.FloatProperty(causticsStartLevel, Styles.causticsStartlevelText);
                if (causticsShallowFadeDistance.floatValue < 0)
                {
                    causticsShallowFadeDistance.floatValue = 0;
                }
                m_MaterialEditor.FloatProperty(causticsShallowFadeDistance, Styles.causticsShallowFadeDistanceText);
                m_MaterialEditor.FloatProperty(causticsScale, Styles.causticsScaleText);
                m_MaterialEditor.VectorProperty(causticsDrift, Styles.causticsDriftText);

                EditorGUI.EndDisabledGroup();
            }

            if (!HasValidEmissiveKeyword(material))
            {
                EditorGUILayout.HelpBox(Styles.emissiveWarning.text, MessageType.Warning);
            }
        }
示例#5
0
        void DoEmissionArea(Material material)
        {
            // Emission for GI?
            if (m_MaterialEditor.EmissionEnabledProperty())
            {
                bool hadEmissionTexture = emissionMap.textureValue != null;

                // Texture and HDR color controls
                m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false);

                // 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);
                m_MaterialEditor.FloatProperty(emissiveBoost, "GI Emissive boost");
            }

            m_MaterialEditor.ShaderProperty(isAVProInput, "Is AVPro input");
        }
        private void AdditionalSettings(Material material)
        {
            //----------------------------------------HDR MULTIPLIER
            //----------------------------------------
            if (Properties.m_HDRMultiplier != null)
            {
                if ((LightingModes)m_LightingMode.floatValue == LightingModes.MultiLightEmissive ||
                    (LightingModes)m_LightingMode.floatValue == LightingModes.LitEmissive)
                {
                    m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_HDRMultiplierText.text);
                    m_MaterialEditor.FloatProperty(Properties.m_HDRMultiplier, Styles.m_HDRMultiplierText.text);
                }
            }
            EditorGUILayout.Space();

            //----------------------------------------SHADOW CUTOFF
            //----------------------------------------
            if (Properties.m_Cutoff != null)
            {
                m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_CutoffText.text);
                m_MaterialEditor.RangeProperty(Properties.m_Cutoff, Styles.m_CutoffText.text);
            }
            EditorGUILayout.Space();

            //----------------------------------------THICKNESS
            //----------------------------------------
            if (Properties.m_Thickness != null)
            {
                m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_ThicknessText.text);
                m_MaterialEditor.RangeProperty(Properties.m_Thickness, Styles.m_ThicknessText.text);
            }
            EditorGUILayout.Space();

            //----------------------------------------ALPHA TRANSMITANCE
            //----------------------------------------
            if (Properties.m_AlphaTransmitance != null)
            {
                var backLight = EditorGUILayout.Toggle(Styles.m_AlphaTransmitanceToggle, m_AlphaTransmitanceEnabled);

                if (backLight)
                {
                    material.EnableKeyword(Keywords.AlphaTransmitance);

                    m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_AlphaTransmitanceText.text);
                    m_MaterialEditor.RangeProperty(Properties.m_AlphaTransmitance, Styles.m_AlphaTransmitanceText.text);
                    m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_AlphaContrastText.text);
                    m_MaterialEditor.RangeProperty(Properties.m_AlphaContrast, Styles.m_AlphaContrastText.text);
                }
                else
                {
                    material.DisableKeyword(Keywords.AlphaTransmitance);
                }
            }
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            //----------------------------------------ADDITIONAL SETTINGS
            //----------------------------------------
            GUILayout.Label(Styles.HeaderOptional, EditorStyles.boldLabel);
            //----------------------------------------SOFT PARTICLES
            //----------------------------------------
            if (Properties.m_InvFade != null)
            {
                var softParticles = EditorGUILayout.Toggle(Styles.m_SoftParticlesToggle, m_SoftParticlesEnabled);

                if (softParticles)
                {
                    material.EnableKeyword(Keywords.SoftParticles);

                    m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_InvFadeText.text);
                    m_MaterialEditor.RangeProperty(Properties.m_InvFade, Styles.m_InvFadeText.text);
                }
                else
                {
                    material.DisableKeyword(Keywords.SoftParticles);
                }
            }
            EditorGUILayout.Space();

            //----------------------------------------DISTANCE FADE
            //----------------------------------------
            if (Properties.m_DistanceFadeStart != null && Properties.m_DistanceFadeEnd != null)
            {
                var distanceFade = EditorGUILayout.Toggle(Styles.m_DistanceFadeToggle, m_DistanceFadeEnabled);

                if (distanceFade)
                {
                    material.EnableKeyword(Keywords.DistanceFade);

                    m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_DistanceFadeStartText.text);
                    m_MaterialEditor.FloatProperty(Properties.m_DistanceFadeStart, Styles.m_DistanceFadeStartText.text);
                    m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_DistanceFadeEndText.text);
                    m_MaterialEditor.FloatProperty(Properties.m_DistanceFadeEnd, Styles.m_DistanceFadeEndText.text);
                }
                else
                {
                    material.DisableKeyword(Keywords.DistanceFade);
                }
            }
        }
示例#7
0
        private void AdditionalSettings(Material material)
        {
            if (m_HDRMultiplier != null)
            {
                if ((LightingModes)m_LightingMode.floatValue == LightingModes.MultiLightEmissive ||
                    (LightingModes)m_LightingMode.floatValue == LightingModes.LitEmissive)
                {
                    m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_HDRMultiplierText.text);
                    m_MaterialEditor.FloatProperty(m_HDRMultiplier, Styles.m_HDRMultiplierText.text);
                }
            }

            EditorGUILayout.Space();

            if (m_Cutoff != null)
            {
                m_MaterialEditor.RangeProperty(m_Cutoff, Styles.m_CutoffText.text);
            }

            EditorGUILayout.Space();

            if (m_Thickness != null)
            {
                m_MaterialEditor.RangeProperty(m_Thickness, Styles.m_ThicknessText.text);
            }

            if (m_Backlight)
            {
                EditorGUI.BeginChangeCheck();
                var backLight = EditorGUILayout.Toggle(Styles.m_BacklightToggle, m_Backlight);
                EditorGUI.EndChangeCheck();
                {
                    m_MaterialEditor.RegisterPropertyChangeUndo(Styles.m_BacklightToggle.text);
                    if (backLight)
                    {
                        material.EnableKeyword("BACKLIGHT_ON");
                    }
                    else
                    {
                        material.DisableKeyword("BACKLIGHT_ON");
                    }
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUILayout.Label(Styles.HeaderOptional, EditorStyles.boldLabel);

            if (m_InvFade != null)
            {
                EditorGUI.BeginChangeCheck();
                var softParticles = EditorGUILayout.Toggle(Styles.m_SoftParticlesToggle, m_SoftParticles);
                EditorGUI.EndChangeCheck();
                {
                    m_MaterialEditor.RegisterPropertyChangeUndo("Enable Soft Particle");
                    if (softParticles)
                    {
                        material.EnableKeyword("SOFTPARTICLE_ON");

                        m_MaterialEditor.RangeProperty(m_InvFade, Styles.m_InvFadeText.text);
                    }
                    else
                    {
                        material.DisableKeyword("SOFTPARTICLE_ON");
                    }
                }
            }

            EditorGUILayout.Space();

            if (m_DistanceFadeStart != null && m_DistanceFadeEnd != null)
            {
                EditorGUI.BeginChangeCheck();
                var distanceFade = EditorGUILayout.Toggle(Styles.m_DistanceFadeToggle, m_DistanceFade);
                EditorGUI.EndChangeCheck();
                {
                    m_MaterialEditor.RegisterPropertyChangeUndo("Distance Fade");
                    if (distanceFade)
                    {
                        material.EnableKeyword("DISTANCEFADE_ON");

                        m_MaterialEditor.FloatProperty(m_DistanceFadeStart, Styles.m_DistanceFadeStartText.text);
                        m_MaterialEditor.FloatProperty(m_DistanceFadeEnd, Styles.m_DistanceFadeEndText.text);
                    }
                    else
                    {
                        material.DisableKeyword("DISTANCEFADE_ON");
                    }
                }
            }
        }
示例#8
0
		override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
			bool inactiveFlag = false;
			if (!checkNormalmapsUsage(editor.target as Material, label)) return;
			if (!checkDetailUsage(editor.target as Material, label)) return;
			if (!checkSpecUsage(editor.target as Material, label)) return;
			#if UNITY_5
				if (prop.name=="unity_SpecCube" || prop.name=="unity_SpecCube1") return;
			#endif

			if (checkVisible (editor, label, ref inactiveFlag)) {
				EditorGUI.BeginDisabledGroup(inactiveFlag);
				switch (prop.type) {
					case MaterialProperty.PropType.Range: // float ranges
					{
						editor.RangeProperty(position, prop, label);
						break;
					}
					case MaterialProperty.PropType.Float: // floats
					{
						editor.FloatProperty(position, prop, label);
						break;
					}
					case MaterialProperty.PropType.Color: // colors
					{
						editor.ColorProperty(position, prop, label);
						break;
					}
					case MaterialProperty.PropType.Texture: // textures
					{
						editor.TextureProperty(position, prop, label, texTileOffset);
						break;
					}
					case MaterialProperty.PropType.Vector: // vectors
					{
						position.x+=12;
						position.width-=12;
						editor.VectorProperty(position, prop, label);
						break;
					}
					default:
					{
						GUILayout.Label("Unknown prop type... ("+label+")");
						break;
					}
				}
				EditorGUI.EndDisabledGroup();
			}
		}