Sorry if it’s repeated question. I went through lot of questions with same kind of problem but hard to find, what i need…
Am using Vuforia Image Target to create AR app, So when user capture an image using camera i will show some GUI Text(ex - Score), which will not have any background at all since the camera will be ON all the time and rendering the real word images.
So i need to create a GUI.box which can give a black background and so i can display the Score in White, which will be visible clearly to the user.
I used GUI.Skin and changed the box background to an Black Texture, what happened is “Score” GUI itself is not visible if i give background texture as black. Am not sure why am getting the problem.
Please guide me on this.
Strange enough, I don’t remember having such an issue before, so I did a simple test to understand how it works and i’ll share it here.
1):
GUI Text’s transform.position.Z = 1
GUI Texture’s transform.position.Z = 5
GUI.depth = 0
2):
GUI Text’s transform.position.Z = 1
GUI Texture’s transform.position.Z = 5
GUI.depth = 10
Result was the same as #1. (Can’t attach more than 2 pictures so I’m not posting a screenshot for this one since it is the same result, you can try and see if you are not convinced.)
3):
GUI Text’s transform.position.Z = 5
GUI Texture’s transform.position.Z = 4
GUI.depth = 3
Conclusion: UnityGUI (the gui you draw using GUI.Box etc.) is drawn AFTER the scene’s camera is done drawing and has nothing to do with the camera’s GUILayer (which is used to draw GUITexts and GUITextures)
GUI.depth is only used for UnityGUI and doesn’t have anything to do with GUITexts and GUITextures.
However, there is a solution for your problem. Instead of using a GUIText, you can draw a text over your GUIBox like:
GUI.Box(boxRectangle, "text you wish to display");