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]
After:
Code: [Select]
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"
相关文章推荐
- Unity中NGUI里ScrollView选中的item遮挡自动滚动到中间或者合适位置
- Unity3d NGUI的使用(四)(TexturePacker与UIAtlas生成prefabs)
- Unity3D基础学习 利用NGUI的Texture播放视频
- NGUI中Scrollview和UIGrid的ResetPosition和RePosition方法总结
- [Unity]Unity开发NGUI代码实现ScrollView(滚动视图)
- android scrollview listview 嵌套, 显示时总是显示listview内容,没有显示到activity顶部问题
- 【Unity3D】【NGUI】如何设置Atlas的Texture
- NGUI官网示例7-- ScrollView讲解(一)
- 解决ConstraintLayout 与ScrollView 嵌套时ScrollView 内容没有完全显示
- Unity_NGUI基础控件_ScrollView_042
- Android中解决ScrollView下拉阴影的问题(ListView也应该可以的,没有亲测)
- 【Unity开发】NGUI动态刷新ScrollView
- NGUI系列教程七(3D视图&ScrollView)
- NGUI官网示例7-- ScrollView讲解(二)
- scrollview嵌套recyclerview时滑动没有惯性的解决
- Unity3d NGUI的使用(四)(TexturePacker与UIAtlas生成prefabs)
- NGUI系列教程七(3D视图&ScrollView)
- NGUI 的ScrollView如何让item居中
- NGUI官网示例7-- ScrollView讲解(三)
- Unity3D开发(二):NGUI Sprite在ScrollView下变灰方案