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; } } }
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; } }