Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Tatanan on February 16, 2015, 06:34:54 AM
-
Hello.
Is there any way to make a mask with NGUI?
By "mask" I mean the mask Flash has, ie, an object which defines which part of another object is shown.
I already know that NGUI does have some kind of mask if you use a UISprite of type Filled. Then adjusting Fill Amount I can show more or less. But I wonder if I can make it better like I did it on Flash.
Example: cutting an image with a starred shape or so.
Thank you.
-
Yes. Panels let you specify a clipping mask texture.
-
As far as I know, panel mask are only rectangular.
Is there any way to use other shapes, like stars, circles, human-shapes or whatever?
I know that Unity UI has this kind of masks, but I don't know if it's compatible with NGUI.
-
Make the texture mask a circle, and there you go. Its a texture mask. Specify whatever you like. All textures are rectangles, doesn't mean that what you see has to be.
-
Oh, I just realised that you could specify a texture on the UIPanel to use as mask.
That's a great feature.
However I'm finding a problem. I'm attaching a screenshot. The mask is not working properly. The UISprite should be masked by a hand shaped mask, but there are also some extra lines on each direction.
-
That's your texture import settings. You have it set to Clamp, and your texture goes all the way to the edges of the texture.
Add some padding pixels.
-
I still don't know how to do it.
After your answer I have tried every texture type and I still can't make a "good" mask. The mask keeps adding 4 extra lines for each direction.
It's the same with other textures. Basically, the mask is not respecting the Size value and it's adding "extra lines".
-
I think you can hack it by giving the mask a 1px border of transparent color.
-
Exactly what Nicki said. The "white" of your texture should never go all the way to the edges of the clamped texture. Clamp = border pixels "repeats" forever.