예제 #1
0
        public static Material GetStencilMaterial(Material baseMaterial, int stencilID)
        {
            if (!baseMaterial.HasProperty(ShaderUtilities.ID_StencilID))
            {
                Debug.LogWarning("Selected Shader does not support Stencil Masking. Please select the Distance Field or Mobile Distance Field Shader.");
                return(baseMaterial);
            }
            int      num = MaterialManager.m_materialList.FindIndex((MaterialManager.MaskingMaterial item) => item.baseMaterial == baseMaterial && item.stencilID == stencilID);
            Material material;

            if (num == -1)
            {
                material           = new Material(baseMaterial);
                material.hideFlags = (HideFlags.HideInHierarchy | HideFlags.DontSaveInEditor | HideFlags.NotEditable);
                Material expr_6F = material;
                expr_6F.name            = expr_6F.name + " Masking ID:" + stencilID;
                material.shaderKeywords = baseMaterial.shaderKeywords;
                ShaderUtilities.GetShaderPropertyIDs();
                material.SetFloat(ShaderUtilities.ID_StencilID, (float)stencilID);
                material.SetFloat(ShaderUtilities.ID_StencilComp, 3f);
                MaterialManager.MaskingMaterial maskingMaterial = new MaterialManager.MaskingMaterial();
                maskingMaterial.baseMaterial    = baseMaterial;
                maskingMaterial.stencilMaterial = material;
                maskingMaterial.stencilID       = stencilID;
                maskingMaterial.count           = 1;
                MaterialManager.m_materialList.Add(maskingMaterial);
            }
            else
            {
                material = MaterialManager.m_materialList.get_Item(num).stencilMaterial;
                MaterialManager.m_materialList.get_Item(num).count++;
            }
            MaterialManager.ListMaterials();
            return(material);
        }
예제 #2
0
        public static void AddMaskingMaterial(Material baseMaterial, Material stencilMaterial, int stencilID)
        {
            int num = MaterialManager.m_materialList.FindIndex((MaterialManager.MaskingMaterial item) => item.stencilMaterial == stencilMaterial);

            if (num == -1)
            {
                MaterialManager.MaskingMaterial maskingMaterial = new MaterialManager.MaskingMaterial();
                maskingMaterial.baseMaterial    = baseMaterial;
                maskingMaterial.stencilMaterial = stencilMaterial;
                maskingMaterial.stencilID       = stencilID;
                maskingMaterial.count           = 1;
                MaterialManager.m_materialList.Add(maskingMaterial);
            }
            else
            {
                stencilMaterial = MaterialManager.m_materialList.get_Item(num).stencilMaterial;
                MaterialManager.m_materialList.get_Item(num).count++;
            }
        }