I’m trying to hide some of the underlaying gui of a GUI.DrawTexture which forms a plane, so that it forms a circle. I’ve currently tried using the Graphics.DrawTexture with a material using the unlit/depth shader, but that shader requires geometry.
I’ve also tried making a round texture, but that doesn’t work either, since i want to use material offset, which results in an circles running across the desired area.
So if anyone know how i can hide some of the gui through code i would very much appreciate your knowledge on this matter.
hard to understand what you are trying to do, got an image to show ?
just trying to make a circular gui object ? use alpha in your texture.
you can draw geometry elements on your gui, in fact its faster than using unity gui. Just set up a second camera, orthographic, and set your plane to be a child of that camera, and you can then use any shader you want on it. suggest not using unity plane as it has 100+ vertices, just get a single quad from somewhere… or use a cube… its cheaper.
Well that is not what i am trying to do. I do not want to use geometry, since that would be simple, but i want to use the built in gui system since i want the gui to scale together with the screen resolution.
I am seeking a way to use Graphics.DrawTexture together with a material that hides the underlaying gui.
still not clear what you are trying to do, can you define this better… “a material that hides the underlaying gui.”
geometry would scale with the screen resolution.
Do you mean that you are trying to draw something on top of an existing gui element, that makes the item underneath it disappear?
Sounds like you need a z-buffer trick, but gui is drawn without z-buffering I think.
I want to make a health globe using built in GUI. This would be very easy since i could just make a circle texture. But the thing i’m trying to achieve is something that looks like diablo 3’s health globes where there’s scrolling textures, so that it looks like the liquid inside the globe is moving. So first i want to draw some planes that uses material offsets and then i want to draw a texture with a cutout circle inside it so that it hides the part of the gui that shouldn’t form a circle.
Is this anyhow possible?
The way to mix 2d and 3d elements in a gui, is to add a second gui camera, orthographic, that only draws 3d objects in a layer you setup “3dGui-layer”
I’d make that diablo effect with a 3D globe attached to camera, with a fixed offset (parented to camera) (camera is orthographic)
with a 2D menu element over the top of it. that 2D menu element could unity Gui, ngui or tk2d plugins.
alternately, you could do it all 2d, with a rendered texture.
you could also do it with a 3d globe, squished into a flat 2d one, and scroll the material UV’s but it might as well be a sphere, that you just rotate.
keeping the 2d element over the 3d element on different screen resolutions might be a problem… depending on how you are positioning the 2D elements, but thats up to you.
You could also make the overlaid 2D element, a plane that gets rendered by your 3d ortho camera, solving the overlay alignment issue.
suggest you always setup gui elements to snap to edges or corners of your screen so they work for all resolutions.