VectorProperty() public method

public VectorProperty ( MaterialProperty prop, string label ) : Vector4
prop MaterialProperty
label string
return Vector4
示例#1
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);
            }
        }
    override public void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) {
        //Debug.Log("OnGUI: " + label + " RTP_MaterialProp");

        if (!parsed)
        {
            parsed = true;
            parsedLabel = RTP_MatPropStringParser.Parse(label);
        }
        label = parsedLabel;

        if (editor is RTP_CustomShaderGUI)
        {
            RTP_CustomShaderGUI customEditor = editor as RTP_CustomShaderGUI;

            if (customEditor.showFlag && (show_for_active_layer == -1 || customEditor.active_layer == show_for_active_layer) && prop.name!= "dummy_end") {

                EditorGUI.BeginDisabledGroup(customEditor.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
                        {
                            EditorGUIUtility.labelWidth -= 30;
                            if (noAlphaFlag)
                            {
                                EditorGUI.ColorField(position, new GUIContent(label, ""), prop.colorValue, true, false, false, null);
                            }
                            else
                            {
                                editor.ColorProperty(position, prop, label);
                            }
                            break;
                        }
                    case MaterialProperty.PropType.Texture: // textures
                        {
                            EditorGUI.BeginChangeCheck();
                            if (miniThumbFlag)
                            {
                                editor.TexturePropertyMiniThumbnail(position, prop, label,"");
                            } else
                            {
                                editor.TextureProperty(position, prop, label, !noTileOffsetFlag);
                            }
                            if (EditorGUI.EndChangeCheck() && prop.textureValue!=null && sharedTextures!=null)
                            {
                                for(int j=0; j<sharedTextures.Length; j++)
                                {
                                    foreach(Material mat in editor.targets)
                                    {
                                        if (mat.HasProperty(sharedTextures[j]))
                                        {
                                            mat.SetTexture(sharedTextures[j], prop.textureValue);
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    case MaterialProperty.PropType.Vector: // vectors
                        {
                            if (byLayerFlag)
                            {
                                //
                                // affect single vector component depending on active layer
                                //
                                int layerNum = customEditor.active_layer;
                                float pval = prop.vectorValue[layerNum];
                                float nval;
                                if (minVal == maxVal)
                                {
                                    // float
                                    EditorGUIUtility.labelWidth -= 23;
                                    nval = EditorGUI.FloatField(position, label, pval);
                                }
                                else
                                {
                                    // slider
                                    EditorGUIUtility.labelWidth = 160;
                                    nval = EditorGUI.Slider(position, label, pval, minVal, maxVal);
                                }
                                if (pval!=nval)
                                {
                                    for(int i=0; i< prop.targets.Length; i++)
                                    {
                                        Material mat = (prop.targets[i] as Material);
                                        Vector4 vec = mat.GetVector(prop.name);
                                        vec[layerNum] = nval;
                                        mat.SetVector(prop.name, vec);
                                    }
                                }
                            }
                            else
                            {
                                position.x += 12;
                                position.width -= 12;
                                editor.VectorProperty(position, prop, label);
                            }
                            break;
                        }
                    default:
                        {
                            if (customEditor.nextLabelWidth>0)
                            {
                                EditorGUIUtility.labelWidth = customEditor.nextLabelWidth;
                                customEditor.nextLabelWidth = 0;
                            } else
                            {
                                EditorGUIUtility.labelWidth -= 30;
                            }
                            editor.DefaultShaderProperty(position, prop, label);
                            break;
                        }
                }

			    EditorGUI.EndDisabledGroup();
		    }
        }

    }
        void DoSpecularMetallicArea()
        {
            // m_MaterialEditor.ColorProperty(lightcol, "_LColor");
            // m_MaterialEditor.VectorProperty(lightpos,"_WSLP");



            m_MaterialEditor.RangeProperty(giglossiness, "GiGlossiness");
            m_MaterialEditor.RangeProperty(gidarkness, "GiDarkness");

            if (m_WorkflowMode == WorkflowMode.Skin)
            {
                // m_MaterialEditor.ColorProperty(skincolor, "SkinColor");
                // m_MaterialEditor.ColorProperty(clothcolor, "ClothColor");
                m_MaterialEditor.RangeProperty(hues, "Skin HVS");
                m_MaterialEditor.RangeProperty(sats, "Skin SAT");
                m_MaterialEditor.RangeProperty(vals, "Skin VAL");
                m_MaterialEditor.RangeProperty(huec, "Cloth HVS");
                m_MaterialEditor.RangeProperty(satc, "Cloth SAT");
                m_MaterialEditor.RangeProperty(valc, "Cloth VAL");
            }
            bool hasGlossMap = false;

            if (m_WorkflowMode == WorkflowMode.Specular)
            {
                hasGlossMap = specularMap.textureValue != null;
                m_MaterialEditor.TexturePropertySingleLine(Styles.specularMapText, specularMap, hasGlossMap ? null : specularColor);
            }
            else if (m_WorkflowMode == WorkflowMode.Gloss || m_WorkflowMode == WorkflowMode.Skin)
            {
                hasGlossMap = metallicMap.textureValue != null;
                m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, hasGlossMap ? null : metallic);
            }

            else if (m_WorkflowMode == WorkflowMode.LMap)
            {
                hasGlossMap = metallicMap.textureValue != null;
                m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, hasGlossMap ? null : metallic);
                m_MaterialEditor.ColorProperty(lightcol, "_LColor");
                m_MaterialEditor.VectorProperty(lightpos, "_WSLP");
            }

            else if (m_WorkflowMode == WorkflowMode.LMap20)
            {
                // hasGlossMap = metallicMap.textureValue != null;
                // m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, hasGlossMap ? null : metallic);
                m_MaterialEditor.ColorProperty(lightcol, "_LColor");
                m_MaterialEditor.VectorProperty(lightpos, "_WSLP");
            }

            bool showSmoothnessScale = hasGlossMap;

            if (smoothnessMapChannel != null)
            {
                int smoothnessChannel = (int)smoothnessMapChannel.floatValue;
                if (smoothnessChannel == (int)SmoothnessMapChannel.AlbedoAlpha)
                {
                    showSmoothnessScale = true;
                }
            }

            //int indentation = 2; // align with labels of texture properties
            //m_MaterialEditor.ShaderProperty(showSmoothnessScale ? smoothnessScale : smoothness, showSmoothnessScale ? Styles.smoothnessScaleText : Styles.smoothnessText, indentation);
            // smoothness = 0.8f;
            // smoothnessScale = 0.8f;
            m_MaterialEditor.RangeProperty(smoothness, "Smoothness value");
            m_MaterialEditor.RangeProperty(smoothnessScale, "Smoothness scale factor");

            //++indentation;
            // if (smoothnessMapChannel != null)
            //     m_MaterialEditor.ShaderProperty(smoothnessMapChannel, Styles.smoothnessMapChannelText, indentation);
        }
示例#4
0
 // Tirgames assets
 void DoTirgamesEmission(Material material)
 {
     m_MaterialEditor.VectorProperty(emissionMapScaleOffset, "Tiling");
 }
示例#5
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();
			}
		}