[UIToolkit] How to draw UIText over any other UIElement in UIToolkit

I am trying to achieve an effect using UIToolkit where I want to draw UIText over some other UIElement.

There is one UIButton that will be drawn multiple times on screen and there will be different text written in the center of those UIButton instances.

Something like in the image attached.

In this image the blue box is the UIButton that is drawn multiple times and there will be different UITextInstances that will be drawn over each of those UIButtons. What I’m trying to achieve is a level selection menu using the UIToolkit.

I tried to get the position of UIButton and then draw text over it by adjusting the position of UITextInstance relative to the UIButton on which it is to be drawn but didn’t suceed.

It would appreciate if someone can point me in the right direction.

1741256--110040--Concept.jpg

Ummm… Anyone…??

if u use the gui function there is something called depth set diffrent depth to your elements to overlay them

It’s been years since i used UIToolkit. From memory, it uses a second orthographic camera (layer filtered) for the UI objects. Have a look for where you can set the Z-axis (Z buffer, Z depth) in the documentation. For example, these are a couple of methods in the UIButton class (reference link : UIToolkit/Assets/Plugins/UIToolkit/UIElements/UIButton.cs at master · oddgames/UIToolkit · GitHub ) :

public static UIButton create( UIToolkit manager, string filename, string highlightedFilename, int xPos, int yPos )
public static UIButton create( UIToolkit manager, string filename, string highlightedFilename, int xPos, int yPos, int depth )

see how the create method has parameters for setting just the X and Y, but also for setting all the positions (XYZ)? This is what you need to use. Specify the depth when creating your UI objects.

Thanks @AlucardJay for reply.

Actually depth is not the issue I’m facing. I would elaborate a little more on the problem.

Since you can not add UIText to a UIScrollableHorizontalLayout, I am not able to add the text over that UIButton.

So how do you suppose to tackle this issue. Any workaround?

Guess, I should wait for Unity 4.6 stable version to release. :slight_smile: