0

I have a sprite widget in NGUI, and It can't be brought to front what ever the depth I change in the editor:

enter image description here

Note that the orange panel is a scroll view of NGUI.

Here is the inspector setting of the sprite that I want to set to the very front:

enter image description here

And here is the inspector setting that has overlapped the above sprite that I want to make front of it.

enter image description here

And here is the BottomPanel setting

enter image description here

armnotstrong
  • 8,605
  • 16
  • 65
  • 130
  • It's the long time I've used NGUI but I think I might be able to help on this one too. Can you take a screenshot of Inspector of the object that is in front of it then post it. Now, take take a screenshot of Inspector of the object that you want to send to the front then post that too. I just want to compare their settings. – Programmer Jun 17 '17 at 08:25
  • @Programmer just wait for me to do that :D – armnotstrong Jun 17 '17 at 08:29
  • @Programmer have pasted the screenshot of the inspector settings – armnotstrong Jun 17 '17 at 08:35
  • This is interesting because it should work with the current settings. Change the z-axis of the "Sprite (1)" object to be 4. Let me know if there is any changes. When I say Z-axis, I mean the position (P) **not** (R) or (S). – Programmer Jun 17 '17 at 08:42
  • Didn't get any luck with the z-axis, but if I drag the "background" out of "BottomPanel" in the Hierarchy things will work though :( – armnotstrong Jun 17 '17 at 08:46
  • And I have added the BottomPanel 's Inspector settings – armnotstrong Jun 17 '17 at 08:48
  • On the UI Panel, it says "Sort Order"...Can you check the "Sort Order"? Tell me what happens. – Programmer Jun 17 '17 at 09:11
  • @Programmer Got no luck there too, But I will dig into that and let you know. – armnotstrong Jun 17 '17 at 09:25
  • Check the answer I left. That should solve your problem. If not, let me know and I will remove it. – Programmer Jun 17 '17 at 09:27
  • Hi, If I put the sprite under the panel then I could make things work just by setting the depth on the NGUI's widget, but since the thing I really want to do is to put the sprite in front of everything ie I want actually put the sprite in the scroll view but since there is sort of mask on the scroll view so when I drag to move that sprite, It will be masked. And I tried the answer you give, Yes it worked, even without setting the **RenderQ** but it's not what I want, Or if there is any way that could make the sprite exception from the scroll view's mask, could solve my problem too – armnotstrong Jun 17 '17 at 09:39
  • Hi @Programmer I have figured this out too, though I didn't really understand what's happening, I solve this by adding another panel set the panel in front of the original one and make the sprite child of the new panel and [this link](http://www.tasharen.com/forum/index.php?topic=1858.0) helps, It maybe all the major pits I have to solve today, thanks for your time and have a good weekend :D – armnotstrong Jun 17 '17 at 09:44
  • I thought in your question that you only wanted to put "Sprite (1)" on top of "background". That's what the answer I provided should do. I don't know about masking and other stuff. If you solved it, you should out your own answer. I will be out for a while but will check your answer when I return. – Programmer Jun 17 '17 at 09:52

2 Answers2

1

I finally solve this problem by

  • Add another panel
  • Setting the added panel in front the origin one
  • Make the sprite child of the newly added panel

And the final hierarchy is like this:

enter image description here

And this link of NGUI forum helps

quoted here:

"Depth" property is used to determine the drawing order of the widgets within the same panel that use the same atlas. If you are using different atlases or labels using a dynamic font, bring the widgets forward on the transform's Z, moving them closer to the camera (-Z). If you are using different panels, adjust the transform of the panel you want to bring in front to a lower negative Z value (-Z). I highly recommend sticking to one atlas if you can manage it, it will make your life significantly easier.

And I make a youtube video to explain what I have achieved so far.

armnotstrong
  • 8,605
  • 16
  • 65
  • 130
0

Everything looks fine to me but it doesn't seem to work for you. There is another workaround.

On the UIPanel, change the Render Q to Explicit then use z-axis to sort your UISprite. I mean the z position (P) not (R) or (S)

For example, change the z-axis of the "Sprite (1)" object to be 2 then change the z-axis of the "background" object to 1. If this does not work, change the values around.

Please make sure that the Sprite is under the panel.

Programmer
  • 121,791
  • 22
  • 236
  • 328