FindProperty() protected static méthode

Find shader properties.

protected static FindProperty ( string propertyName, MaterialProperty properties ) : MaterialProperty
propertyName string Name of the material property.
properties MaterialProperty The array of available properties.
Résultat MaterialProperty
Exemple #1
0
 internal void DetermineWorkflow(MaterialProperty[] props)
 {
     if (ShaderGUI.FindProperty("_SpecGlossMap", props, false) != null && ShaderGUI.FindProperty("_SpecColor", props, false) != null)
     {
         this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Specular;
     }
     else if (ShaderGUI.FindProperty("_MetallicGlossMap", props, false) != null && ShaderGUI.FindProperty("_Metallic", props, false) != null)
     {
         this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Metallic;
     }
     else
     {
         this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Dielectric;
     }
 }
Exemple #2
0
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            if (!this.m_Initialized)
            {
                this.m_ShowLatLongLayout.valueChanged.AddListener(new UnityAction(materialEditor.Repaint));
                this.m_ShowMirrorOnBack.valueChanged.AddListener(new UnityAction(materialEditor.Repaint));
                this.m_Show3DControl.valueChanged.AddListener(new UnityAction(materialEditor.Repaint));
                this.m_Initialized = true;
            }
            float labelWidth = EditorGUIUtility.labelWidth;

            materialEditor.SetDefaultGUIWidths();
            this.ShowProp(materialEditor, ShaderGUI.FindProperty("_Tint", props));
            this.ShowProp(materialEditor, ShaderGUI.FindProperty("_Exposure", props));
            this.ShowProp(materialEditor, ShaderGUI.FindProperty("_Rotation", props));
            this.ShowProp(materialEditor, ShaderGUI.FindProperty("_MainTex", props));
            EditorGUIUtility.labelWidth     = labelWidth;
            this.m_ShowLatLongLayout.target = (this.ShowProp(materialEditor, ShaderGUI.FindProperty("_Mapping", props)) == 1f);
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowLatLongLayout.faded))
            {
                this.m_ShowMirrorOnBack.target = (this.ShowProp(materialEditor, ShaderGUI.FindProperty("_ImageType", props)) == 1f);
                if (EditorGUILayout.BeginFadeGroup(this.m_ShowMirrorOnBack.faded))
                {
                    EditorGUI.indentLevel++;
                    this.ShowProp(materialEditor, ShaderGUI.FindProperty("_MirrorOnBack", props));
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndFadeGroup();
                this.m_Show3DControl.value = false;
                BuildPlatform[] buildPlatforms = BuildPlatforms.instance.buildPlatforms;
                for (int i = 0; i < buildPlatforms.Length; i++)
                {
                    BuildPlatform buildPlatform = buildPlatforms[i];
                    if (VREditor.GetVREnabledOnTargetGroup(buildPlatform.targetGroup))
                    {
                        this.m_Show3DControl.value = true;
                        break;
                    }
                }
                if (EditorGUILayout.BeginFadeGroup(this.m_Show3DControl.faded))
                {
                    this.ShowProp(materialEditor, ShaderGUI.FindProperty("_Layout", props));
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.EndFadeGroup();
            materialEditor.PropertiesDefaultGUI(new MaterialProperty[0]);
        }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            materialEditor.SetDefaultGUIWidths();
            MaterialProperty materialProperty = ShaderGUI.FindProperty("_SunDisk", props);

            SkyboxProceduralShaderGUI.SunDiskMode sunDiskMode = (SkyboxProceduralShaderGUI.SunDiskMode)materialProperty.floatValue;
            for (int i = 0; i < props.Length; i++)
            {
                if ((props[i].flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) == MaterialProperty.PropFlags.None)
                {
                    if (!(props[i].name == "_SunSizeConvergence") || sunDiskMode == SkyboxProceduralShaderGUI.SunDiskMode.HighQuality)
                    {
                        float propertyHeight = materialEditor.GetPropertyHeight(props[i], props[i].displayName);
                        Rect  controlRect    = EditorGUILayout.GetControlRect(true, propertyHeight, EditorStyles.layerMaskField, new GUILayoutOption[0]);
                        materialEditor.ShaderProperty(controlRect, props[i], props[i].displayName);
                    }
                }
            }
        }
 public void FindProperties(MaterialProperty[] props)
 {
     this.blendMode     = ShaderGUI.FindProperty("_Mode", props);
     this.albedoMap     = ShaderGUI.FindProperty("_MainTex", props);
     this.albedoColor   = ShaderGUI.FindProperty("_Color", props);
     this.alphaCutoff   = ShaderGUI.FindProperty("_Cutoff", props);
     this.specularMap   = ShaderGUI.FindProperty("_SpecGlossMap", props, false);
     this.specularColor = ShaderGUI.FindProperty("_SpecColor", props, false);
     this.metallicMap   = ShaderGUI.FindProperty("_MetallicGlossMap", props, false);
     this.metallic      = ShaderGUI.FindProperty("_Metallic", props, false);
     if (this.specularMap != null && this.specularColor != null)
     {
         this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Specular;
     }
     else
     {
         if (this.metallicMap != null && this.metallic != null)
         {
             this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Metallic;
         }
         else
         {
             this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Dielectric;
         }
     }
     this.smoothness                = ShaderGUI.FindProperty("_Glossiness", props);
     this.bumpScale                 = ShaderGUI.FindProperty("_BumpScale", props);
     this.bumpMap                   = ShaderGUI.FindProperty("_BumpMap", props);
     this.heigtMapScale             = ShaderGUI.FindProperty("_Parallax", props);
     this.heightMap                 = ShaderGUI.FindProperty("_ParallaxMap", props);
     this.occlusionStrength         = ShaderGUI.FindProperty("_OcclusionStrength", props);
     this.occlusionMap              = ShaderGUI.FindProperty("_OcclusionMap", props);
     this.emissionScaleUI           = ShaderGUI.FindProperty("_EmissionScaleUI", props);
     this.emissionColorUI           = ShaderGUI.FindProperty("_EmissionColorUI", props);
     this.emissionColorForRendering = ShaderGUI.FindProperty("_EmissionColor", props);
     this.emissionMap               = ShaderGUI.FindProperty("_EmissionMap", props);
     this.detailMask                = ShaderGUI.FindProperty("_DetailMask", props);
     this.detailAlbedoMap           = ShaderGUI.FindProperty("_DetailAlbedoMap", props);
     this.detailNormalMapScale      = ShaderGUI.FindProperty("_DetailNormalMapScale", props);
     this.detailNormalMap           = ShaderGUI.FindProperty("_DetailNormalMap", props);
     this.uvSetSecondary            = ShaderGUI.FindProperty("_UVSec", props);
 }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            if (m_FirstTimeApply)
            {
                foreach (var obj in materialEditor.targets)
                {
                    MaterialChanged((Material)obj);
                }
                m_FirstTimeApply = false;
            }

            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0.0f;

            EditorGUI.BeginChangeCheck();
            {
                GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);

                // color
                var colorTexProp = ShaderGUI.FindProperty("_MainTex", properties);
                var colorProp    = ShaderGUI.FindProperty("_Color", properties);
                materialEditor.TexturePropertySingleLine(Styles.colorText, colorTexProp, null, colorProp);

                // normal
                var normalTexProp = ShaderGUI.FindProperty("_BumpMap", properties);
                materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalTexProp);

                // extra
                var extraTexProp = ShaderGUI.FindProperty("_ExtraTex", properties);
                materialEditor.TexturePropertySingleLine(Styles.extraMapText, extraTexProp, null);
                if (extraTexProp.textureValue == null)
                {
                    var glossProp = ShaderGUI.FindProperty("_Glossiness", properties);
                    materialEditor.ShaderProperty(glossProp, Styles.smoothnessText, 2);
                    var metallicProp = ShaderGUI.FindProperty("_Metallic", properties);
                    materialEditor.ShaderProperty(metallicProp, Styles.metallicText, 2);
                }

                // subsurface
                var ssTexProp = ShaderGUI.FindProperty("_SubsurfaceTex", properties);
                var ssProp    = ShaderGUI.FindProperty("_SubsurfaceColor", properties);
                materialEditor.TexturePropertySingleLine(Styles.subsurfaceMapText, ssTexProp, null, ssProp);

                // Emission
                emissionColorForRendering = ShaderGUI.FindProperty("_EmissionColor", properties);
                emissionMap = ShaderGUI.FindProperty("_EmissionMap", properties);
                emissionMap.textureScaleAndOffset = colorTexProp.textureScaleAndOffset;


                // other options
                EditorGUILayout.Space();
                GUILayout.Label(Styles.optionsText, EditorStyles.boldLabel);

                MakeAlignedProperty(FindProperty("_TwoSided", properties), Styles.twoSidedText, materialEditor, true);
                MakeAlignedProperty(FindProperty("_WindQuality", properties), Styles.windQualityText, materialEditor, true);
                MakeCheckedProperty(FindProperty("_HueVariationKwToggle", properties), FindProperty("_HueVariationColor", properties), Styles.hueVariationText, materialEditor);
                MakeAlignedProperty(FindProperty("_NormalMapKwToggle", properties), Styles.normalMappingText, materialEditor, true);

                // subsurface
                var subsurfaceToggle = FindProperty("_SubsurfaceKwToggle", properties);
                MakeAlignedProperty(subsurfaceToggle, Styles.subsurfaceText, materialEditor, true);
                if (subsurfaceToggle.floatValue > 0.0f)
                {
                    var sssIndirectProp = ShaderGUI.FindProperty("_SubsurfaceIndirect", properties);
                    materialEditor.ShaderProperty(sssIndirectProp, Styles.subsurfaceIndirectText, 2);
                }

                // billboard
                var billboardToggle = FindProperty("_BillboardKwToggle", properties);
                MakeAlignedProperty(billboardToggle, Styles.billboardText, materialEditor, true);
                if (billboardToggle.floatValue > 0.0f)
                {
                    var prop = ShaderGUI.FindProperty("_BillboardShadowFade", properties);
                    materialEditor.ShaderProperty(prop, Styles.billboardShadowFadeText, 2);
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var obj in materialEditor.targets)
                {
                    Material mat = (Material)obj;
                    MaterialChanged(mat);
                }
            }

            EditorGUILayout.Space();
            GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
            materialEditor.EnableInstancingField();
            materialEditor.DoubleSidedGIField();

            // Emission for GI?
            m_MaterialEditor = materialEditor;
            if (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);


                SetKeyword((Material)m_MaterialEditor.target, "EFFECT_EMISSION", true);
            }
            else
            {
                SetKeyword((Material)m_MaterialEditor.target, "EFFECT_EMISSION", false);
            }
        }
Exemple #6
0
 protected static MaterialProperty FindProperty(string propertyName, MaterialProperty[] properties)
 {
     return(ShaderGUI.FindProperty(propertyName, properties, true));
 }
        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
        {
            // Use default labelWidth
            EditorGUIUtility.labelWidth = 0.0f;

            {
                GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);

                // color
                var colorTexProp = ShaderGUI.FindProperty("_MainTex", properties);
                var colorProp    = ShaderGUI.FindProperty("_Color", properties);
                materialEditor.TexturePropertySingleLine(Styles.colorText, colorTexProp, null, colorProp);

                // normal
                var normalTexProp = ShaderGUI.FindProperty("_BumpMap", properties);
                materialEditor.TexturePropertySingleLine(Styles.normalMapText, normalTexProp);

                // extra
                var extraTexProp = ShaderGUI.FindProperty("_ExtraTex", properties);
                materialEditor.TexturePropertySingleLine(Styles.extraMapText, extraTexProp, null);
                if (extraTexProp.textureValue == null)
                {
                    var glossProp = ShaderGUI.FindProperty("_Glossiness", properties);
                    materialEditor.ShaderProperty(glossProp, Styles.smoothnessText, 2);
                    var metallicProp = ShaderGUI.FindProperty("_Metallic", properties);
                    materialEditor.ShaderProperty(metallicProp, Styles.metallicText, 2);
                }

                // subsurface
                var ssTexProp = ShaderGUI.FindProperty("_SubsurfaceTex", properties);
                var ssProp    = ShaderGUI.FindProperty("_SubsurfaceColor", properties);
                materialEditor.TexturePropertySingleLine(Styles.subsurfaceMapText, ssTexProp, null, ssProp);

                // other options
                EditorGUILayout.Space();
                GUILayout.Label(Styles.optionsText, EditorStyles.boldLabel);

                MakeAlignedProperty(FindProperty("_TwoSided", properties), Styles.twoSidedText, materialEditor, true);
                MakeAlignedProperty(FindProperty("_WindQuality", properties), Styles.windQualityText, materialEditor, true);
                MakeCheckedProperty(FindProperty("_HueVariationKwToggle", properties), FindProperty("_HueVariationColor", properties), Styles.hueVariationText, materialEditor);
                MakeAlignedProperty(FindProperty("_NormalMapKwToggle", properties), Styles.normalMappingText, materialEditor, true);

                // subsurface
                var subsurfaceToggle = FindProperty("_SubsurfaceKwToggle", properties);
                MakeAlignedProperty(subsurfaceToggle, Styles.subsurfaceText, materialEditor, true);
                if (subsurfaceToggle.floatValue > 0.0f)
                {
                    var sssIndirectProp = ShaderGUI.FindProperty("_SubsurfaceIndirect", properties);
                    materialEditor.ShaderProperty(sssIndirectProp, Styles.subsurfaceIndirectText, 2);
                }

                // billboard
                var billboardToggle = FindProperty("_BillboardKwToggle", properties);
                MakeAlignedProperty(billboardToggle, Styles.billboardText, materialEditor, true);
                if (billboardToggle.floatValue > 0.0f)
                {
                    var prop = ShaderGUI.FindProperty("_BillboardShadowFade", properties);
                    materialEditor.ShaderProperty(prop, Styles.billboardShadowFadeText, 2);
                }
            }

            EditorGUILayout.Space();
            GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
            materialEditor.EnableInstancingField();
            materialEditor.DoubleSidedGIField();
        }