Example #1
0
        /// <summary>
        /// Function returning the modified material for masking if necessary.
        /// </summary>
        /// <param name="baseMaterial"></param>
        /// <returns></returns>
        public override Material GetModifiedMaterial(Material baseMaterial)
        {
            Material mat = baseMaterial;

            if (m_ShouldRecalculateStencil)
            {
                m_StencilValue             = TMP_MaterialManager.GetStencilID(gameObject);
                m_ShouldRecalculateStencil = false;
            }

            if (m_StencilValue > 0)
            {
                mat = TMP_MaterialManager.GetStencilMaterial(baseMaterial, m_StencilValue);
                if (m_MaskMaterial != null)
                {
                    TMP_MaterialManager.ReleaseStencilMaterial(m_MaskMaterial);
                }

                m_MaskMaterial = mat;
            }
            else if (m_MaskMaterial != null)
            {
                TMP_MaterialManager.ReleaseStencilMaterial(m_MaskMaterial);
            }

            return(mat);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="baseMaterial"></param>
        /// <returns></returns>
        public override Material GetModifiedMaterial(Material baseMaterial)
        {
            Material mat = baseMaterial;

            if (m_ShouldRecalculateStencil)
            {
                m_stencilID = TMP_MaterialManager.GetStencilID(gameObject);
                m_ShouldRecalculateStencil = false;
            }

            // Release masking material
            //if (m_MaskMaterial != null)
            //    MaterialManager.ReleaseStencilMaterial(m_MaskMaterial);

            if (m_stencilID > 0)
            {
                mat = TMP_MaterialManager.GetStencilMaterial(baseMaterial, m_stencilID);
                if (m_MaskMaterial != null)
                {
                    TMP_MaterialManager.ReleaseStencilMaterial(m_MaskMaterial);
                }

                m_MaskMaterial = mat;
            }

            return(mat);
        }
        public override Material GetModifiedMaterial(Material baseMaterial)
        {
            Material material = baseMaterial;

            if (this.m_ShouldRecalculateStencil)
            {
                this.m_StencilValue             = TMP_MaterialManager.GetStencilID(base.gameObject);
                this.m_ShouldRecalculateStencil = false;
            }
            if (this.m_StencilValue > 0)
            {
                material = TMP_MaterialManager.GetStencilMaterial(baseMaterial, this.m_StencilValue);
                if (this.m_MaskMaterial != null)
                {
                    TMP_MaterialManager.ReleaseStencilMaterial(this.m_MaskMaterial);
                }
                this.m_MaskMaterial = material;
            }
            return(material);
        }