- Home /
How to Change GUI.BOX background to black ?
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.
am instantiating set of GUI Text's as a prefab and introducing GUI.Box using OnGUI() at a later point of time...is that cause any issue ??
Answer by Shrandis · Oct 04, 2012 at 08:06 AM
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");
Thanks a lot Shrandis...It helps a lot and give clear picture to me....
Thank you so much :-)
Your answer
Follow this Question
Related Questions
how to scale GUI box without bearing a constant ratio among width and height? 1 Answer
How to remove GUI window box and display just the texture? 1 Answer
how to Display time after game complete 1 Answer
GUI Menu Esc Button to Show and Hide it? 2 Answers
Why does my GUI health bar move sideways when it I lose health? 1 Answer