I have an object composed of a GUITexture and a GUIText on top of it. There is one of these objects for each nearby character.
Unfortunately, they don’t layer correctly - although I can get GUITextures to layer themselves correcty (closer characters’ labels showing up on top of farther ones), the GUITexts attached to these GUITextures seem to be immutably on top of all GUITextures.
I’ve tried that - the Text is a child of the texture, and whetever its local position is (positive or negative), it’s always on top of the texture (and all other textures)
Ive had some strange things happen when parenting GuiTextures and GuiTexts before.
Generally, the way I solved the problem was to use int ZOrders for all guielements and also set the zorder for each object independently of its relationship with the parent. (i.e. a Parent GUITexture with Z=1 and the GUIText Z=2).
I know this explanation might sound a bit simple, but ive found this technique to be very stable when using 3D objects to position 2D element zorders.
I still haven’t got a solution to this - properly ordering their Z positions doesn’t work. Thought I’d bump it because it’s become a pretty serious graphical problem.
I feel like some sort of putz. How do I change the “local” z position vs the global one? I only see the one Z property in the transform panel. Is there a way to toggle between local and global for the panel that I’m not seeing?
I don’t see a z-position for the guitexture or text, just a z-position for the game object itself to which the guitext is attached, and if I change this the text won’t display in the proper position. Isn’t there a stacking order unrelated to the object’s actual position within the world?
While what Eric5h5 says is true, that doesn’t answer your question, which is the same one I had:
So if both the GUIText and the GUITexture are on the same GameObject (and thus have the same Z), and you want them to appear in a specific order, you have to add the components to the GameObject in the order you want them displayed (from top to bottom in the inspector).
Example: I have a panel GameObject, and it contains both the panel background (GUITexture) and the panel text (GUIText). I obviously need the text to appear in front of the panel. So I add the GUIText first (higher in the inspector) and the GUITexture last (lower down in the inspector).
Oh Oh OH WOW! I am pretty *(W@JFSD at myself now. For months, I’ve avoided GUITextures and GUItext, due to the fact that I couldn’t get the “z” values to actually work, and ALL THIS TIME, I’ve been trying to change the “Scale” Z’s instead of the Position Z’s… Oh wow, this is really dumb, (of me), but so helpful here on this post! Thank-you!