GetMaterialProperties() public static method

public static GetMaterialProperties ( UnityEngine mats ) : UnityEditor.MaterialProperty[]
mats UnityEngine
return UnityEditor.MaterialProperty[]
        public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
        {
            base.AssignNewShaderToMaterial(material, oldShader, newShader);

            if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
            {
                return;
            }

            BlendMode blendMode = BlendMode.Opaque;

            if (oldShader.name.Contains("/Transparent/Cutout/"))
            {
                blendMode = BlendMode.Cutout;
            }
            else if (oldShader.name.Contains("/Transparent/"))
            {
                // NOTE: legacy shaders did not provide physically based transparency
                // therefore Fade mode
                blendMode = BlendMode.Fade;
            }
            material.SetFloat("_Mode", (float)blendMode);

            DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[] { material }));
            MaterialChanged(material, m_WorkflowMode);
        }
Beispiel #2
0
        public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
        {
            // _Emission property is lost after assigning Standard shader to the material
            // thus transfer it before assigning the new shader
            if (material.HasProperty("_Emission"))
            {
                material.SetColor("_EmissionColor", material.GetColor("_Emission"));
            }

            base.AssignNewShaderToMaterial(material, oldShader, newShader);

            if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
            {
                SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode"));
                return;
            }

            BlendMode blendMode = BlendMode.Opaque;

            if (oldShader.name.Contains("/Transparent/Cutout/"))
            {
                blendMode = BlendMode.Cutout;
            }
            else if (oldShader.name.Contains("/Transparent/"))
            {
                // NOTE: legacy shaders did not provide physically based transparency
                // therefore Fade mode
                blendMode = BlendMode.Fade;
            }
            material.SetFloat("_Mode", (float)blendMode);
            //material.SetFloat("_Mix", (float)mixMode);

            DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[] { material }));
            MaterialChanged(material, m_WorkflowMode);
        }
Beispiel #3
0
        public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
        {
            // _Emission property is lost after assigning Standard shader to the material
            // thus transfer it before assigning the new shader
            if (material.HasProperty("_Emission"))
            {
                material.SetColor("_EmissionColor", material.GetColor("_Emission"));
            }

            base.AssignNewShaderToMaterial(material, oldShader, newShader);

            if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
            {
                return;
            }

            BlendMode blendMode = BlendMode.Opaque;

            // RTP - geom blend uses only transparent (fade), but we don't replace any defaults

//		if (oldShader.name.Contains("/Transparent/Cutout/"))
//		{
//			blendMode = BlendMode.Cutout;
//		}
//		else if (oldShader.name.Contains("/Transparent/"))
//		{
//			// NOTE: legacy shaders did not provide physically based transparency
//			// therefore Fade mode
//			blendMode = BlendMode.Fade;
//		}
            material.SetFloat("_Mode", (float)blendMode);

            DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[] { material }));
            MaterialChanged(material, m_WorkflowMode);
        }
Beispiel #4
0
 public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
 {
     if (material.HasProperty("_Emission"))
     {
         material.SetColor("_EmissionColor", material.GetColor("_Emission"));
     }
     base.AssignNewShaderToMaterial(material, oldShader, newShader);
     if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
     {
         StandardShaderGUI.SetupMaterialWithBlendMode(material, (StandardShaderGUI.BlendMode)material.GetFloat("_Mode"));
     }
     else
     {
         StandardShaderGUI.BlendMode blendMode = StandardShaderGUI.BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             blendMode = StandardShaderGUI.BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             blendMode = StandardShaderGUI.BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float)blendMode);
         this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[]
         {
             material
         }));
         StandardShaderGUI.MaterialChanged(material, this.m_WorkflowMode);
     }
 }
        public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
        {
            base.AssignNewShaderToMaterial(material, oldShader, newShader);
            if ((UnityEngine.Object)oldShader == (UnityEngine.Object)null || !oldShader.name.Contains("Legacy Shaders/"))
            {
                return;
            }
            EDStandardShaderGUI.BlendMode blendMode = EDStandardShaderGUI.BlendMode.Opaque;
            if (oldShader.name.Contains("/Transparent/Cutout/"))
            {
                blendMode = EDStandardShaderGUI.BlendMode.Cutout;
            }
            else if (oldShader.name.Contains("/Transparent/"))
            {
                blendMode = EDStandardShaderGUI.BlendMode.Fade;
            }
            material.SetFloat("_Mode", (float)blendMode);
            Material[] materialArray = new Material[1];
            int        index         = 0;
            Material   material1     = material;

            materialArray[index] = material1;
            this.DetermineWorkflow(MaterialEditor.GetMaterialProperties((UnityEngine.Object[])materialArray));
            EDStandardShaderGUI.MaterialChanged(material, this.m_WorkflowMode);
        }
Beispiel #6
0
 public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
 {
     if (material.HasProperty("_Emission"))
     {
         material.SetColor("_EmissionColor", material.GetColor("_Emission"));
     }
     base.AssignNewShaderToMaterial(material, oldShader, newShader);
     if ((oldShader == null) || !oldShader.name.Contains("Legacy Shaders/"))
     {
         SetupMaterialWithBlendMode(material, (BlendMode)((int)material.GetFloat("_Mode")));
     }
     else
     {
         BlendMode opaque = BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             opaque = BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             opaque = BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float)opaque);
         Material[] mats = new Material[] { material };
         this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(mats));
         MaterialChanged(material, this.m_WorkflowMode);
     }
 }
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            SerializedProperty property = base.serializedObject.FindProperty("m_Shader");

            if ((base.isVisible && !property.hasMultipleDifferentValues) && (property.objectReferenceValue != null))
            {
                List <MaterialProperty> list = new List <MaterialProperty>(MaterialEditor.GetMaterialProperties(base.targets));
                base.SetDefaultGUIWidths();
                SpeedTreeGeometryType[] source = new SpeedTreeGeometryType[base.targets.Length];
                for (int i = 0; i < base.targets.Length; i++)
                {
                    source[i] = SpeedTreeGeometryType.Branch;
                    for (int j = 0; j < this.speedTreeGeometryTypeString.Length; j++)
                    {
                        if (((Material)base.targets[i]).shaderKeywords.Contains <string>(this.speedTreeGeometryTypeString[j]))
                        {
                            source[i] = (SpeedTreeGeometryType)j;
                            break;
                        }
                    }
                }
                EditorGUI.showMixedValue = source.Distinct <SpeedTreeGeometryType>().Count <SpeedTreeGeometryType>() > 1;
                EditorGUI.BeginChangeCheck();
                SpeedTreeGeometryType geomType = (SpeedTreeGeometryType)EditorGUILayout.EnumPopup("Geometry Type", source[0], new GUILayoutOption[0]);
                if (EditorGUI.EndChangeCheck())
                {
                    bool     flag = this.ShouldEnableAlphaTest(geomType);
                    CullMode mode = !flag ? CullMode.Back : CullMode.Off;
                    IEnumerator <Material> enumerator = base.targets.Cast <Material>().GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            Material current = enumerator.Current;
                            for (int k = 0; k < this.speedTreeGeometryTypeString.Length; k++)
                            {
                                current.DisableKeyword(this.speedTreeGeometryTypeString[k]);
                            }
                            current.EnableKeyword(this.speedTreeGeometryTypeString[(int)geomType]);
                            current.renderQueue = !flag ? 0x7d0 : 0x992;
                            current.SetInt("_Cull", (int)mode);
                        }
                    }
                    finally
                    {
                        if (enumerator == null)
                        {
                        }
                        enumerator.Dispose();
                    }
                }
                EditorGUI.showMixedValue = false;
                if (< > f__am$cache1 == null)
                {
Beispiel #8
0
        //$$$--------------------------------------
        // This is the first time the shader has been initialized
        //$$$--------------------------------------
        public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
        {
            // _Emission property is lost after assigning Standard shader to the material
            // thus transfer it before assigning the new shader
            if (material.HasProperty("_Emission"))
            {
                material.SetColor("_EmissionColor", material.GetColor("_Emission"));
            }

            base.AssignNewShaderToMaterial(material, oldShader, newShader);

            //$$$--------------------------------------
            material.SetFloat("_Mode", (float)BlendMode.Cutout);
            material.SetFloat("_Cutoff", 0.000001f);
            material.SetFloat("_ZWrite", 0);
            material.renderQueue = (int)RenderQueue.AlphaTest + 1;
            Styles.renderQueue   = material.renderQueue - (int)RenderQueue.AlphaTest;
            //$$$--------------------------------------

            if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
            {
                //$$$--------------------------------------
                SetupMaterialWithBlendMode(material, BlendMode.Cutout);
                //SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode"));
                //$$$--------------------------------------
                return;
            }

            //$$$--------------------------------------
            //BlendMode blendMode = BlendMode.Opaque;
            //if (oldShader.name.Contains("/Transparent/Cutout/"))
            //{
            //    blendMode = BlendMode.Cutout;
            //}
            //else if (oldShader.name.Contains("/Transparent/"))
            //{
            //    // NOTE: legacy shaders did not provide physically based transparency
            //    // therefore Fade mode
            //    blendMode = BlendMode.Fade;
            //}
            //material.SetFloat("_Mode", (float)blendMode);
            //$$$--------------------------------------

            DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[] { material }));
            MaterialChanged(material, m_WorkflowMode);

            //$$$--------------------------------------
            material.SetFloat("_Mode", (float)BlendMode.Cutout);
            material.SetFloat("_Cutoff", 0.000001f);
            material.SetFloat("_ZWrite", 0);
            material.renderQueue = (int)RenderQueue.AlphaTest + 1;
            Styles.renderQueue   = material.renderQueue - (int)RenderQueue.AlphaTest;
            //$$$--------------------------------------
        }
        public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
        {
            base.AssignNewShaderToMaterial(material, oldShader, newShader);

            if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
            {
                return;
            }

            DetermineWorkflow(MaterialEditor.GetMaterialProperties(new Material[] { material }));
            MaterialChanged(material, m_WorkflowMode);
        }
 public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
 {
     base.AssignNewShaderToMaterial(material, oldShader, newShader);
     if ((oldShader != null) && oldShader.name.Contains("Legacy Shaders/"))
     {
         BlendMode opaque = BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             opaque = BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             opaque = BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float)opaque);
         Material[] mats = new Material[] { material };
         this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(mats));
         MaterialChanged(material, this.m_WorkflowMode);
     }
 }
Beispiel #11
0
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            SerializedProperty serializedProperty = base.serializedObject.FindProperty("m_Shader");

            if (!base.isVisible || serializedProperty.hasMultipleDifferentValues || serializedProperty.objectReferenceValue == null)
            {
                return;
            }
            List <MaterialProperty> list = new List <MaterialProperty>(MaterialEditor.GetMaterialProperties(base.targets));

            base.SetDefaultGUIWidths();
            SpeedTreeMaterialInspector.SpeedTreeGeometryType[] array = new SpeedTreeMaterialInspector.SpeedTreeGeometryType[base.targets.Length];
            for (int i = 0; i < base.targets.Length; i++)
            {
                array[i] = SpeedTreeMaterialInspector.SpeedTreeGeometryType.Branch;
                for (int j = 0; j < this.speedTreeGeometryTypeString.Length; j++)
                {
                    if (((Material)base.targets[i]).shaderKeywords.Contains(this.speedTreeGeometryTypeString[j]))
                    {
                        array[i] = (SpeedTreeMaterialInspector.SpeedTreeGeometryType)j;
                        break;
                    }
                }
            }
            EditorGUI.showMixedValue = (array.Distinct <SpeedTreeMaterialInspector.SpeedTreeGeometryType>().Count <SpeedTreeMaterialInspector.SpeedTreeGeometryType>() > 1);
            EditorGUI.BeginChangeCheck();
            SpeedTreeMaterialInspector.SpeedTreeGeometryType speedTreeGeometryType = (SpeedTreeMaterialInspector.SpeedTreeGeometryType)EditorGUILayout.EnumPopup("Geometry Type", array[0], new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                bool     flag  = this.ShouldEnableAlphaTest(speedTreeGeometryType);
                CullMode value = (!flag) ? CullMode.Back : CullMode.Off;
                foreach (Material current in base.targets.Cast <Material>())
                {
                    for (int k = 0; k < this.speedTreeGeometryTypeString.Length; k++)
                    {
                        current.DisableKeyword(this.speedTreeGeometryTypeString[k]);
                    }
                    current.EnableKeyword(this.speedTreeGeometryTypeString[(int)speedTreeGeometryType]);
                    current.renderQueue = ((!flag) ? 2000 : 2450);
                    current.SetInt("_Cull", (int)value);
                }
            }
            EditorGUI.showMixedValue = false;
            MaterialProperty materialProperty = list.Find((MaterialProperty prop) => prop.name == "_MainTex");

            if (materialProperty != null)
            {
                list.Remove(materialProperty);
                base.ShaderProperty(materialProperty, materialProperty.displayName);
            }
            MaterialProperty materialProperty2 = list.Find((MaterialProperty prop) => prop.name == "_BumpMap");

            if (materialProperty2 != null)
            {
                list.Remove(materialProperty2);
                IEnumerable <bool> source =
                    from t in base.targets
                    select((Material)t).shaderKeywords.Contains("EFFECT_BUMP");

                bool?flag2 = this.ToggleShaderProperty(materialProperty2, source.First <bool>(), source.Distinct <bool>().Count <bool>() > 1);
                if (flag2.HasValue)
                {
                    foreach (Material current2 in base.targets.Cast <Material>())
                    {
                        if (flag2.Value)
                        {
                            current2.EnableKeyword("EFFECT_BUMP");
                        }
                        else
                        {
                            current2.DisableKeyword("EFFECT_BUMP");
                        }
                    }
                }
            }
            MaterialProperty materialProperty3 = list.Find((MaterialProperty prop) => prop.name == "_DetailTex");

            if (materialProperty3 != null)
            {
                list.Remove(materialProperty3);
                if (array.Contains(SpeedTreeMaterialInspector.SpeedTreeGeometryType.BranchDetail))
                {
                    base.ShaderProperty(materialProperty3, materialProperty3.displayName);
                }
            }
            IEnumerable <bool> enumerable =
                from t in base.targets
                select((Material)t).shaderKeywords.Contains("EFFECT_HUE_VARIATION");

            MaterialProperty materialProperty4 = list.Find((MaterialProperty prop) => prop.name == "_HueVariation");

            if (enumerable != null && materialProperty4 != null)
            {
                list.Remove(materialProperty4);
                bool?flag3 = this.ToggleShaderProperty(materialProperty4, enumerable.First <bool>(), enumerable.Distinct <bool>().Count <bool>() > 1);
                if (flag3.HasValue)
                {
                    foreach (Material current3 in base.targets.Cast <Material>())
                    {
                        if (flag3.Value)
                        {
                            current3.EnableKeyword("EFFECT_HUE_VARIATION");
                        }
                        else
                        {
                            current3.DisableKeyword("EFFECT_HUE_VARIATION");
                        }
                    }
                }
            }
            MaterialProperty materialProperty5 = list.Find((MaterialProperty prop) => prop.name == "_Cutoff");

            if (materialProperty5 != null)
            {
                list.Remove(materialProperty5);
                if (array.Any((SpeedTreeMaterialInspector.SpeedTreeGeometryType t) => this.ShouldEnableAlphaTest(t)))
                {
                    base.ShaderProperty(materialProperty5, materialProperty5.displayName);
                }
            }
            foreach (MaterialProperty current4 in list)
            {
                if ((current4.flags & MaterialProperty.PropFlags.HideInInspector) == MaterialProperty.PropFlags.None)
                {
                    base.ShaderProperty(current4, current4.displayName);
                }
            }
        }
Beispiel #12
0
        public override void OnInspectorGUI()
        {
            this.serializedObject.Update();
            SerializedProperty property = this.serializedObject.FindProperty("m_Shader");

            if (!this.isVisible || property.hasMultipleDifferentValues || property.objectReferenceValue == (UnityEngine.Object)null)
            {
                return;
            }
            List <MaterialProperty> materialPropertyList = new List <MaterialProperty>((IEnumerable <MaterialProperty>)MaterialEditor.GetMaterialProperties(this.targets));

            this.SetDefaultGUIWidths();
            SpeedTreeMaterialInspector.SpeedTreeGeometryType[] treeGeometryTypeArray = new SpeedTreeMaterialInspector.SpeedTreeGeometryType[this.targets.Length];
            for (int index1 = 0; index1 < this.targets.Length; ++index1)
            {
                treeGeometryTypeArray[index1] = SpeedTreeMaterialInspector.SpeedTreeGeometryType.Branch;
                for (int index2 = 0; index2 < this.speedTreeGeometryTypeString.Length; ++index2)
                {
                    if (((IEnumerable <string>)((Material)this.targets[index1]).shaderKeywords).Contains <string>(this.speedTreeGeometryTypeString[index2]))
                    {
                        treeGeometryTypeArray[index1] = (SpeedTreeMaterialInspector.SpeedTreeGeometryType)index2;
                        break;
                    }
                }
            }
            EditorGUI.showMixedValue = ((IEnumerable <SpeedTreeMaterialInspector.SpeedTreeGeometryType>)treeGeometryTypeArray).Distinct <SpeedTreeMaterialInspector.SpeedTreeGeometryType>().Count <SpeedTreeMaterialInspector.SpeedTreeGeometryType>() > 1;
            EditorGUI.BeginChangeCheck();
            SpeedTreeMaterialInspector.SpeedTreeGeometryType geomType = (SpeedTreeMaterialInspector.SpeedTreeGeometryType)EditorGUILayout.EnumPopup("Geometry Type", (Enum)treeGeometryTypeArray[0], new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                bool     flag     = this.ShouldEnableAlphaTest(geomType);
                CullMode cullMode = !flag ? CullMode.Back : CullMode.Off;
                foreach (Material material in this.targets.Cast <Material>())
                {
                    for (int index = 0; index < this.speedTreeGeometryTypeString.Length; ++index)
                    {
                        material.DisableKeyword(this.speedTreeGeometryTypeString[index]);
                    }
                    material.EnableKeyword(this.speedTreeGeometryTypeString[(int)geomType]);
                    material.renderQueue = !flag ? 2000 : 2450;
                    material.SetInt("_Cull", (int)cullMode);
                }
            }
            EditorGUI.showMixedValue = false;
            MaterialProperty prop1 = materialPropertyList.Find((Predicate <MaterialProperty>)(prop => prop.name == "_MainTex"));

            if (prop1 != null)
            {
                materialPropertyList.Remove(prop1);
                this.ShaderProperty(prop1, prop1.displayName);
            }
            MaterialProperty prop2 = materialPropertyList.Find((Predicate <MaterialProperty>)(prop => prop.name == "_BumpMap"));

            if (prop2 != null)
            {
                materialPropertyList.Remove(prop2);
                IEnumerable <bool> source = ((IEnumerable <UnityEngine.Object>) this.targets).Select <UnityEngine.Object, bool>((Func <UnityEngine.Object, bool>)(t => ((IEnumerable <string>)((Material)t).shaderKeywords).Contains <string>("EFFECT_BUMP")));
                bool?nullable             = this.ToggleShaderProperty(prop2, source.First <bool>(), source.Distinct <bool>().Count <bool>() > 1);
                if (nullable.HasValue)
                {
                    foreach (Material material in this.targets.Cast <Material>())
                    {
                        if (nullable.Value)
                        {
                            material.EnableKeyword("EFFECT_BUMP");
                        }
                        else
                        {
                            material.DisableKeyword("EFFECT_BUMP");
                        }
                    }
                }
            }
            MaterialProperty prop3 = materialPropertyList.Find((Predicate <MaterialProperty>)(prop => prop.name == "_DetailTex"));

            if (prop3 != null)
            {
                materialPropertyList.Remove(prop3);
                if (((IEnumerable <SpeedTreeMaterialInspector.SpeedTreeGeometryType>)treeGeometryTypeArray).Contains <SpeedTreeMaterialInspector.SpeedTreeGeometryType>(SpeedTreeMaterialInspector.SpeedTreeGeometryType.BranchDetail))
                {
                    this.ShaderProperty(prop3, prop3.displayName);
                }
            }
            IEnumerable <bool> source1 = ((IEnumerable <UnityEngine.Object>) this.targets).Select <UnityEngine.Object, bool>((Func <UnityEngine.Object, bool>)(t => ((IEnumerable <string>)((Material)t).shaderKeywords).Contains <string>("EFFECT_HUE_VARIATION")));
            MaterialProperty   prop4   = materialPropertyList.Find((Predicate <MaterialProperty>)(prop => prop.name == "_HueVariation"));

            if (source1 != null && prop4 != null)
            {
                materialPropertyList.Remove(prop4);
                bool?nullable = this.ToggleShaderProperty(prop4, source1.First <bool>(), source1.Distinct <bool>().Count <bool>() > 1);
                if (nullable.HasValue)
                {
                    foreach (Material material in this.targets.Cast <Material>())
                    {
                        if (nullable.Value)
                        {
                            material.EnableKeyword("EFFECT_HUE_VARIATION");
                        }
                        else
                        {
                            material.DisableKeyword("EFFECT_HUE_VARIATION");
                        }
                    }
                }
            }
            MaterialProperty prop5 = materialPropertyList.Find((Predicate <MaterialProperty>)(prop => prop.name == "_Cutoff"));

            if (prop5 != null)
            {
                materialPropertyList.Remove(prop5);
                if (((IEnumerable <SpeedTreeMaterialInspector.SpeedTreeGeometryType>)treeGeometryTypeArray).Any <SpeedTreeMaterialInspector.SpeedTreeGeometryType>((Func <SpeedTreeMaterialInspector.SpeedTreeGeometryType, bool>)(t => this.ShouldEnableAlphaTest(t))))
                {
                    this.ShaderProperty(prop5, prop5.displayName);
                }
            }
            using (List <MaterialProperty> .Enumerator enumerator = materialPropertyList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    MaterialProperty current = enumerator.Current;
                    if ((current.flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) == MaterialProperty.PropFlags.None)
                    {
                        this.ShaderProperty(current, current.displayName);
                    }
                }
            }
        }
Beispiel #13
0
        private void ShowPropertyBlock(int index, Material mat, MaterialPropertyBlock block)
        {
            #region check paramter
            if (mat == null)
            {
                EditorGUILayout.LabelField("mat is null.");
                return;
            }
            if (block == null)
            {
                EditorGUILayout.LabelField("block is null.");
                return;
            }
            #endregion

            MaterialProperty[] props = MaterialEditor.GetMaterialProperties(new Material[] { mat });
            for (var i = 0; i < props.Length; i++)
            {
                MaterialProperty          prop        = props[i];
                string                    name        = prop.name;
                string                    displayName = prop.displayName;
                MaterialProperty.PropType type        = prop.type;
                switch (type)
                {
                case MaterialProperty.PropType.Color:
                {
                    Color value    = block.GetColor(name);
                    Color newValue = EditorGUILayout.ColorField(GetName(displayName, name), value);
                    if (newValue != value)
                    {
                        m_viewer.SetValue(index, name, newValue);
                    }
                }
                break;

                case MaterialProperty.PropType.Vector:
                {
                    Vector4 value    = block.GetVector(name);
                    Vector4 newValue = EditorGUILayout.Vector4Field(GetName(displayName, name), value);
                    if (newValue != value)
                    {
                        m_viewer.SetValue(index, name, newValue);
                    }
                }
                break;

                case MaterialProperty.PropType.Float:
                {
                    float value    = block.GetFloat(name);
                    float newValue = EditorGUILayout.FloatField(GetName(displayName, name), value);
                    if (newValue != value)
                    {
                        m_viewer.SetValue(index, name, newValue);
                    }
                }
                break;

                case MaterialProperty.PropType.Range:
                {
                    float value    = block.GetFloat(name);
                    float newValue = EditorGUILayout.FloatField(GetName(displayName, name), value);
                    if (newValue != value)
                    {
                        m_viewer.SetValue(index, name, newValue);
                    }
                }
                break;

                case MaterialProperty.PropType.Texture:
                {
                    Texture value    = block.GetTexture(name);
                    Texture newValue = EditorGUILayout.ObjectField(
                        GetName(displayName, name), value, typeof(Texture), true) as Texture;
                    if (newValue != value)
                    {
                        m_viewer.SetValue(index, name, newValue);
                    }
                }
                break;

                default:
                {
                }
                break;
                }
            }
        }