How to create a mask.

Anyone know how to do the mask at around 24:11 in this video

The current build doesn’t seem to expose the same Mask values. In the docs for Mask, it says this, “By using this element any children elements that have masking enabled will mask where a sibling Graphic would write 0 to the alpha buffer.”
So I created a script for the TitleBar and referenced the Image script, and set the maskable property on the Image script to true, but it still doesn’t work. What am I still missing?

edit:Well it seems the Image maskable property is set to true by default, so setting it to true by hand does nothing.

1 Like

After hours trying to figure this out, apparently you just have to add an Image script and a Mask script to the object that you want to be the Mask.

1 Like

Yes, we decoupled the mask from the other elements. Now any graphic can be a mask!

having problems here with masks! When using them on a standalone build they work as expected. But as soon as i switch to android in the build settings the masks are broken. I tried to deactivate an reactivate the game objects but nothing… only switching back to standalone fix this.

Anyone else having the same issue?

I had one today where my hierarchy was like so:

Canvas
—Panel
------Image (with mask)
---------Item
---------Item
etc…

When the mask was on the image, it masks out everything below it regardless of where it is vs. the image rect. However, if I move it up to the panel, then it works fine.

Seems like there’s a lot of loose ends and ‘special magic combinations’ you have to understand with this system (Like the fact that mask needs an image component to work even though you don’t intend to draw the image). I’ve spent most of the day trying to make a simple combo box, and will likely need to spend another day or two yet.

You need to make sure you have the project configured with a 24 bit depth / 8 bit stencil buffer. It’s in the android player settings.

While the 24 bit depth did the trick on newer android devices but testing the mask on a Galaxy Nexus resulted in only the mask image being shown.

2 Likes

well that would be bad if it only supports newer phones.

1 Like

Yeah that’d be a show-stopper, but it’s not all bad. Apparently the mask still works on older phones however it also shows the mask graphic on top even if the option’s unchecked. Using a transparent image for the mask works as a temporary solution though.

1 Like

that seems to hide all the children too?

no matter if i use “None (Sprite)” with color set to transparent, or a new transparent image

“You need to make sure you have the project configured with a 24 bit depth / 8 bit stencil buffer. It’s in the android player settings.”

i can find a setting for 24 bit depth buffer it defaults to on anyway
but where is the 8 bit stencil buffer setting?

1773054--112409--Untitled.png

Same for me here. Masks only show the mask image (and not the masked objects) on the Galaxy Nexus running Android 4.2.2. This is for Unity 4.6 RC1, and the 24 bit depth has been set.

2 Likes

ya just tested again with rc1 and my simple mask still does not work on my galaxy nexus?
i wonder if this is a galaxy nexus problem or a mask problem
does anyone have an issue open for this?
thanks