Hi, I want to reveal only a part of a texture. Something like this arrow full arrow: http://forum.piedixterra.com/pxt-games//images/fragger_game.jpg half arrow: http://gamezville.net/files/images/top/fragger.jpg How to do this best for the iPhone? Here is the arrow in action: http://www.youtube.com/watch?v=ckd3jWXbIXE
The best way to do this on iPhone is to move the vertices and UV coordinates of your mesh so that they only cover the part of the texture you want shown. Doing this with shaders means more materials, which means more draw calls. That's really bad on the iPhone.
Fill alpha channel with black-to-white gradient, and then just change Cutoff value in standart "Transparent/Cutout" shader.
if a move vertices the texture will be only scaled. If i move UVs then i can not reveal only a part of the texture. I will see always the top of the arrow
I made a post about this a couple days ago but decided I didn't like the look of my suggestion in practice, so I deleted the post. I agree with this, but the problem comes from the fact that the arrow can fade in and out. So, it requires a different material than everything else I see on screen. That's what I thought at first, but I don't think it plays nicely with blending. The edge of the meter flickered in and out on my MacBook Pro when using a combination of alpha testing and blending, so I imagine it would look as bad or worse on an iOS device. That's why he used the word "and". It must be both. Here's my solution. It's got blending, power meter level changing, and the ability to switch to a different-looking texture when you can't use the arrow (greyed out); it's all done in a single pass. You can play with the custom Inspector for the script to test it out. Go into play mode and you can trigger the opacity-changing function with a button in the Inspector.
alpha blending and cutout is actually one of those areas where the powerVR gpu is worlds different from desktop gpus so always test ideas on the real device instead of assuming things basing on the desktop as there is no guarantee that it will be the same in any way actually (that rule though applies to anything: if being sure costs you 5mins, better invest those 2 mins as early as possible instead of assume things. You don't lose much but can gain a lot from it)