1
NGUI 3 Support / Allow certain 3D objects to overlap certain UI elements
« on: December 29, 2014, 03:24:04 PM »
Hi,
I'm new to Unity so if the question I'm asking indicates that I misunderstand some fundamental concept in Unity and there is another approach to what I'm trying to do I would appreciate anyone sharing it.
So I have characters in my world and those characters have their names hovering above their heads. The names are gameobjects added under UI Root having a UILabel attached to them. UIFollowTarget's game camera is set to the main camera and UI camera is set to the NGUI's Camera (under UI Root).
Since the names are NGUI objects, they are drawn by the NGUI Camera which has a depth of 1 whereas my main game camera has a depth of 0. (I would imagine this is a pretty standard setup.) Now, my character names are always on top, although the characters themselves might be hidden behind home walls or other characters or other 3D objects, even terrain. I would like to apply the same occlusion culling to my labels just like it's applied to characters themselves. This will give it a more natural look.
What is the best way to do it?
I attached a screenshot to illustrate what I mean. The character in the front is the main player character and it doesn't have a name. The character in the back, partially hidden behind the hill, is an NPC with his name floating above him. (Actually more like at his feet, but it doesn't matter for now.) You can see that this label overlaps my main character and the terrain. What I would like to have in this case is just a "ter" visible to the right from the hill's edge, or maybe the entire label hidden altogether.
I'm new to Unity so if the question I'm asking indicates that I misunderstand some fundamental concept in Unity and there is another approach to what I'm trying to do I would appreciate anyone sharing it.
So I have characters in my world and those characters have their names hovering above their heads. The names are gameobjects added under UI Root having a UILabel attached to them. UIFollowTarget's game camera is set to the main camera and UI camera is set to the NGUI's Camera (under UI Root).
Since the names are NGUI objects, they are drawn by the NGUI Camera which has a depth of 1 whereas my main game camera has a depth of 0. (I would imagine this is a pretty standard setup.) Now, my character names are always on top, although the characters themselves might be hidden behind home walls or other characters or other 3D objects, even terrain. I would like to apply the same occlusion culling to my labels just like it's applied to characters themselves. This will give it a more natural look.
What is the best way to do it?
I attached a screenshot to illustrate what I mean. The character in the front is the main player character and it doesn't have a name. The character in the back, partially hidden behind the hill, is an NPC with his name floating above him. (Actually more like at his feet, but it doesn't matter for now.) You can see that this label overlaps my main character and the terrain. What I would like to have in this case is just a "ter" visible to the right from the hill's edge, or maybe the entire label hidden altogether.
