- Home /
Canvas with mask and transparent image
So if I use a mask to hide overlapping ui elements in my canvas (which is placed in world space) it also needs an Image comp. This image component causes the canvas to have a non transparent background which I dont want, so my current hack looks like this:
canvas.AddComponent<Image>().color = new Color(0, 0, 0, 3f / 255f);
canvas.AddComponent<Mask>();
I don't like it and on iOS it seems to cause problems, additionally it probably has some performance drawbacks.
Does someone know how to do this the right way?
Are you maybe trying to do something that the UI has a native handler for? Why do you need to hide overlapping elements? What do you mean?
Generally I just want to use a $$anonymous$$ask in combination with a transparent Image
$$anonymous$$ask in general is very useful for UI for example if you place a canvas as a 3d element in the scene
Answer by Dinosaurs · Nov 20, 2015 at 01:33 PM
If you set showMaskGraphic to false on the Mask, the image should be invisible.
http://docs.unity3d.com/ScriptReference/UI.Mask-showMaskGraphic.html