Exemplo n.º 1
0
        private void ApplyMaskToUIElement(Graphic mGraphic, Mask maskTarget)
        {
            bool maskeeMaterialUsed = maskTarget.IsMaskeeMaterial(mGraphic.material);

            if (IsSupported2DShader(mGraphic.material.shader) || maskeeMaterialUsed)
            {
                UIMaterialModifier modifier = mGraphic.gameObject.GetComponent <UIMaterialModifier>();
                if (modifier == null)
                {
                    modifier = mGraphic.gameObject.AddComponent <UIMaterialModifier>();
                }

                if (!maskeeMaterialUsed)
                {
                    mGraphic.material = maskTarget.SpritesAlphaMaskWorldCoords;
                }
            }
        }
Exemplo n.º 2
0
        private void ApplyMaskToSpriteRenderer(SpriteRenderer spriteRenderer, Mask maskTarget)
        {
            Material materialToReplace = spriteRenderer.sharedMaterial;

            if (materialToReplace == null)
            {
                return;
            }

            if (!maskTarget.IsMaskeeMaterial(materialToReplace))
            {
                if (IsSupported2DShader(spriteRenderer.sharedMaterial.shader))
                {
                    materialToReplace = maskTarget.SpritesAlphaMaskWorldCoords;
                }
                spriteRenderer.sharedMaterial = materialToReplace;
            }
        }