Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Tatanan on February 16, 2015, 06:34:54 AM

Title: Mask with NGUI
Post 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.
Title: Re: Mask with NGUI
Post by: ArenMook on February 17, 2015, 09:24:10 PM
Yes. Panels let you specify a clipping mask texture.
Title: Re: Mask with NGUI
Post by: Tatanan on February 18, 2015, 03:19:57 AM
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.
Title: Re: Mask with NGUI
Post by: ArenMook on February 18, 2015, 05:06:19 PM
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.
Title: Re: Mask with NGUI
Post by: Tatanan on February 19, 2015, 03:21:31 AM
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.
Title: Re: Mask with NGUI
Post by: ArenMook on February 19, 2015, 02:05:42 PM
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.
Title: Re: Mask with NGUI
Post by: Tatanan on February 20, 2015, 03:28:56 AM
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".
Title: Re: Mask with NGUI
Post by: Nicki on February 20, 2015, 03:33:30 AM
I think you can hack it by giving the mask a 1px border of transparent color.
Title: Re: Mask with NGUI
Post by: ArenMook on February 21, 2015, 08:09:58 AM
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.