您的位置:首页 > 产品设计 > UI/UE

NGUI中scrollview中的texture没有被clipped

2012-07-20 16:26 288 查看
问:

When scrolling texture ends up behind panel

I'm having a bit of a problem with shaders and textures getting hidden behind panels. I have textures loaded dynamically and placed into table cells.
When I use a "Unlit - transparent cutout" shader all I have to do is set the Z position for the texture to -1 and it will always appear in front of the panel. However, that shader doesn't allow textures to be clipped properly when they are scrolled off the
panel. Either all of the texture is displayed or all of it becomes clipped. So I need to use something like "Unlit - transparent coloured (soft clip)". This clips the texture beautifully when scrolled, but when Z= -1 it ends up behind the panel as I scroll.
The further I scroll, the more I need to change Z in order for the texture to still appear. So after I have scrolled I need the Z to be -18 so I can still see the texture. I can't have Z values that are too extreme because my main panel rotates around the
Y-axis (via iPhone swipe). Anything that juts out too far looks bad when the main panel spins, so this is not a good solution. I noticed if I have "depth pass" set to TRUE then I only need the Z value of the texture to be -1 and it always appears in front
of the panel and clips nicely, but the bit that is clipped becomes grey, not transparent. I'm sure I'm doing something wrong here. I've attached screen grabs of the different scenarios to explain it better

回答:
This is because you're using a 3D camera.
Clipped views don't mix with 3D UIs very well, especially if you use different atlases.

There is an easy solution though. Modify the Unlit - Transparent Colored (SoftClip) shader to use a +1 render queue, like so:

Before:

Code: [Select]

"Queue" = "Transparent"


After:

Code: [Select]

"Queue" = "Transparent+1"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: