Exemplo n.º 1
0
        // this is used to update a material's keywords, applying any shader-associated logic to update dependent properties and keywords
        // this is also invoked when a material is created, modified, or the material's shader is modified or reassigned
        internal static void UpdateMaterial(Material material, MaterialUpdateType updateType, ShaderID shaderID = ShaderID.Unknown)
        {
            // if unknown, look it up from the material's shader
            // NOTE: this will only work for asset-based shaders..
            if (shaderID == ShaderID.Unknown)
            {
                shaderID = GetShaderID(material.shader);
            }

            switch (shaderID)
            {
            case ShaderID.Lit:
                LitShader.SetMaterialKeywords(material, LitGUI.SetMaterialKeywords);
                break;

            case ShaderID.SimpleLit:
                SimpleLitShader.SetMaterialKeywords(material, SimpleLitGUI.SetMaterialKeywords);
                break;

            case ShaderID.Unlit:
                UnlitShader.SetMaterialKeywords(material);
                break;

            case ShaderID.ParticlesLit:
                ParticlesLitShader.SetMaterialKeywords(material, LitGUI.SetMaterialKeywords, ParticleGUI.SetMaterialKeywords);
                break;

            case ShaderID.ParticlesSimpleLit:
                ParticlesSimpleLitShader.SetMaterialKeywords(material, SimpleLitGUI.SetMaterialKeywords, ParticleGUI.SetMaterialKeywords);
                break;

            case ShaderID.ParticlesUnlit:
                ParticlesUnlitShader.SetMaterialKeywords(material, null, ParticleGUI.SetMaterialKeywords);
                break;

            case ShaderID.SG_Lit:
                ShaderGraphLitGUI.UpdateMaterial(material, updateType);
                break;

            case ShaderID.SG_Unlit:
                ShaderGraphUnlitGUI.UpdateMaterial(material, updateType);
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        static void UpgradeV1(Material material, ShaderID shaderID)
        {
            if (shaderID.IsShaderGraph())
            {
                return;
            }

            var shaderPath  = ShaderUtils.GetShaderPath((ShaderPathID)shaderID);
            var upgradeFlag = MaterialUpgrader.UpgradeFlags.LogMessageWhenNoUpgraderFound;

            switch (shaderID)
            {
            case ShaderID.Unlit:
                MaterialUpgrader.Upgrade(material, new UnlitUpdaterV1(shaderPath), upgradeFlag);
                UnlitShader.SetMaterialKeywords(material);
                break;

            case ShaderID.SimpleLit:
                MaterialUpgrader.Upgrade(material, new SimpleLitUpdaterV1(shaderPath), upgradeFlag);
                SimpleLitShader.SetMaterialKeywords(material, SimpleLitGUI.SetMaterialKeywords);
                break;

            case ShaderID.Lit:
                MaterialUpgrader.Upgrade(material, new LitUpdaterV1(shaderPath), upgradeFlag);
                LitShader.SetMaterialKeywords(material, LitGUI.SetMaterialKeywords);
                break;

            case ShaderID.ParticlesLit:
                MaterialUpgrader.Upgrade(material, new ParticleUpdaterV1(shaderPath), upgradeFlag);
                ParticlesLitShader.SetMaterialKeywords(material, LitGUI.SetMaterialKeywords, ParticleGUI.SetMaterialKeywords);
                break;

            case ShaderID.ParticlesSimpleLit:
                MaterialUpgrader.Upgrade(material, new ParticleUpdaterV1(shaderPath), upgradeFlag);
                ParticlesSimpleLitShader.SetMaterialKeywords(material, SimpleLitGUI.SetMaterialKeywords, ParticleGUI.SetMaterialKeywords);
                break;

            case ShaderID.ParticlesUnlit:
                MaterialUpgrader.Upgrade(material, new ParticleUpdaterV1(shaderPath), upgradeFlag);
                ParticlesUnlitShader.SetMaterialKeywords(material, null, ParticleGUI.SetMaterialKeywords);
                break;
            }
        }