- Home /
Masking GameObject's GuiTexture
Hey there!
I'm trying to make some sort of timer in unity in the shape of an "Hour Glass". What i have is a .png file of an Hour Glass transparent on the inside so its basically an hour glass frame. I also have another .png of the sand inside the hour glass. something like this:
Now, how I went with this is that i have a GameObject with a GuiTexture attached to it with the first picture of the Hour Glass. And also, I have two other GameObjects both with the same GuiTexture of the sand picture, One of the is placed in the top of the Hour Glass transparent part and the other is placed below the bottom of the HourGlass rotated upside down so that the pointy part of the sand is on the top.
What I did is I made an Update method that after each second it decreases the Y pixel inset of the first sand texture and increases the Y pixel inset of the second sand texture, so it looks like sand is dropping from the top and its filling in the bottom part.
I'm aware that it might not be a correct approach for this, and I am open to any other idea in case it works better than this, but basically my problem is that i don't want to see the sand while its outside the borders of the hour glass, both the bottom part when its still halfway inside the hour glass and the top part when it pops out of the edges due to the wider part of the sand being in the narrow part of the hour glass, also I don't want to see the the part of the top sand piece that is below the hour glass narrow neck part.
I tried using a shader i found somewhere but because of no experience with shaders i couldn't make it work.
Could anyone please suggest some way i could go with it?
Thanks to everyone in advance!
Your answer
Follow this Question
Related Questions
How to create a timer with the new UI text? 1 Answer
Texture offset problem. 1 Answer
Carving the ground similar to the game "where's my water?" 0 Answers
Unity3D Timer. 1 Answer
Making GUI Buttons on a GUI Texture 1 Answer