3

I am having issues with Unity 5 / Android and masking. In version 4.6 the mask works as expected. However, I can not get it to work at all in Unity 5.

I have attached two images of what it should look like and what it does look like if anyone could shed any light onto the matter please; do I need specific settings for Android etc??? I am currently working on a blank project to try and get this sorted, so there is no code at present, just the scene.

This is how it SHOULD look This is how it DOES look

3 Answers3

4

I searched a long time for the answer to this but I fixed this problem in Unity 5 by unchecking the "Disable Depth and Stencil*" Box.

Build Settings -> Player Settings -> Resolution and Presentation -> Disable Depth and Stencil

After that you need to re-launch unity (you will not see working mask if you dont)

grinry
  • 421
  • 1
  • 7
  • 17
0

Works Perfectly Fine for me.

Try to do this on a blank Scene.

Add UI Image. -> Will automatically make a Canvas.

On the Image-> Add Component. "Mask".

Now on the Image <- GameObject that you make, Add another Image. Name it Image2.

So you have something like.

Canvas->Image-> Image2.

Now go to Image with Mask component. And on the Mask Component TURN OFF "SHOW MASK GRAPHIC" <- Important.

Now for Image 2. Try to Change the BackGround them Move the Object around while looking in the GAME Window.

Aizen
  • 1,807
  • 2
  • 14
  • 28
  • Thanks for your response @Aizen. Did you run this on a device? What you are suggesting I do is exactly what I did, except I have 3 tiers of images (border, mask, inset). The images I posted are from the editor (which works as it should) and from a physical device (which doesn't work). –  Mar 24 '15 at 10:38
  • Hmmm. This might be an issue with the Tegra Note as I've now tested this in an emulator (Genymotion Nexus 5) and also Xperia Z3 (Sony remote test lab) and they both mask correctly. –  Mar 24 '15 at 11:47
  • Yes, I have used this kind of Masking to all my devices and works fine. I don't have Tegra though. We have 2 kind of mask Component way back, but now in Unity 5 I can only see, Mask <- so I guess they have put out the other one, also the they have changed the Rect Transform property of PosX Pos Y to Left and Right. Which is now a read only and can only be overriden by SetPos(). But doesn't work in Unity5 but works in 4.6, Good thing I still have 4.6, you might want to try 4.6 with the masking and check wether it is the update that is making the mask wont work on your device. – Aizen Mar 24 '15 at 14:50
  • Hi again @Aizen. Yes, the masking works fine in 4.6 (I have both 4.6 and 5.0 installed on the same machine while I try to upgrade my projects to version 5). I think this is a Tegra 4 issue (I have reported it as a bug) as if I use my emulator (Genymotion Nexus 5 or Sony remote labs Xperia Z3) the masking works fine. It's just so annoying because there are fatures I'd like to use from version 5 which I can't until they sort this masking issue out. Thanks for taking the time to look at and try and help resolve this issue. –  Mar 24 '15 at 20:48
  • It doesn't work for me in my Xperia Z3 and I have also tested it in a Nexus 4 and Nexus 7. I can't make masking work in Unity5 for (at least) these Android devices. I have to say that it works perfectly fine for other platforms (Editor, iOS and Web). – FranMowinckel Apr 29 '15 at 17:07
  • more data: With Unity 5.1.2 we're seeing masking work fine on a wide variety of Android devices (including Nexus 7), but not work at all on Nabi Dream Tab running android 4.4.2. – orion elenzil Oct 14 '15 at 17:20
0

It's a late answer. However, To answer what OP asked, I would say using RectMask2D instead of the regular Mask could be a good workaround.

I've also provided another answer to a similar question with some images showing more details.

RectMask2D Control:

A common use of a RectMask2D is to show small sections of a larger area and to somehow frame this area.

The limitations of RectMask2D control are:

  • It only works in 2D space
  • It will not properly mask elements that are not coplanar

The advantages of RectMask2D are:

  • It does not use the stencil buffer
  • No extra draw calls
  • No material changes
  • Fast performance

Reference

Bahman_Aries
  • 4,658
  • 6
  • 36
  • 60