Does UMG ZOrder even work?

Does UMG ZOrder even work?

https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/114751-does-umg-zorder-even-work

Does UMG ZOrder even work?

04-09-2017, 03:14 AM

I have a widget that I display when the user mouses over parts of the UI, kind of like a tooltip, but with my own custom features. Anyway, I add this "tooltip" widget to the viewport and I give it a ZOrder of some high number, like 100 or 1000. However it never draws on top of the other widgets in the viewport. It doesn't matter what I set the ZOrder to it always draws in the same order. The only solution I've found is to remove it from the viewport and then add it back to the viewport again. This puts it on top over everything else, even if I leave its ZOrder set to 0. Does the ZOrder not work? Is it a bug or a known issue? Is there any disadvantages to removing from and then adding again to the viewport?

Tags: None


I actually have the same issue and I don't know of a good solution.

The disadvantage of removing and adding is that you pay a cost in performance whenever you add a widget to viewport. The cost is very small if the widget is lite, say just some border with text in the cast of a tooltip so it's acceptable. In my case I remove and add an inventory with a 100 slots, that is buttons with textures, and it is very noticeable.

 

The Z Order works for elements inside of the same widget.
Widget ordering will come from the order you add them to the viewport.

Right. I kind of came to this conclusion as well after fiddling with it. The strange thing is that I'm adding my tooltip widget to the viewport last, so it "should" be on top of everything else, but it isn't. It is on top of some widgets, but not others. To fix the problem, I have to wait a Tick, then remove the tooltip widget from the viewport, then add it back in. Really weird.

 

The general idea behind it is to have a master widget with a canvas covering the area where the widgets are to be zOrdered and add it to the viewport. Whenever you create gameplay widgets, instead of adding them to the viewport as usual, add them as children of the master widget's canvas (masterWidget --> Canvas --> AddChildToCanvas). This will allow you to control their position, size and, most importantly, the zOrder. In other words, what BrUnO said.

 

(2)

Unreal Engine 4 Documentation > Unreal Engine Blueprint API Reference > Layout > Canvas Slot > Set ZOrder

https://docs.unrealengine.com/en-US/BlueprintAPI/Layout/CanvasSlot/SetZOrder/index.html

(3)

UMG widgets ordering

https://answers.unrealengine.com/questions/134523/view.html

 

4

1

When im adding widgets to CanvasPanel in UMG editor they dont respect displaying order.

alt text

In example above i was adding Image widgets directly to canvas panel, each image was moved to the right and down. As you can see brown and light red images are drawn in bad order.

Even worse, when adding another image, order of those already added is mixed up:

alt text

As you can see Turquoise image now is in front, and only thing i did was adding new image to canvas.

Am i doing something wrong? Z-Order in all of those images is default that is 0, and im aware that i can adjust their draw order by changing Z-Order but i think that images that are added in certain order, and are displayed in that order in hierarchy, should respect that hierarchy when drawing.

Also i dont see any way to change widget position in hierarchy (or to choose place where new widget should be in hierarchy). It seems like if i have 10 widgets on canvas and i want to swap hierarchy order of widgets 3rd and 7th only way is to remove them from parent and placing them once again in different order.

Product Version: Not Selected

标签:bug reporteditorumgquestion

1.png (15.7 kB)

2.png (15.5 kB)

更多 ▼

已提出 Nov 18 '14 在 6:39 PM

Jakub Gałecki
26 ● 1 ● 1 ● 4

avatar image BaronPumpky Nov 25 '14 在 5:40 AM

1

I'm curious about this as well! I've been learning UMG for a few weeks and this has plagued me ever since I started.


2 解答: sort 最早投票 ▼

2

Hello Jakub Gałecki,

You would be correct in assuming that you will need to set the Zorder for everything on your Designer tab that overlaps. Hierarchy does not necessarily determine what shows as on top. As for rearranging widgets in the hierarchy, you will need to click and drag them. When dropped on a widget that can hold it as a child widget the widget will then be placed under it. You can also reorder the widget by clicking and dragging them upward in the hierarchy.

更多 ▼

已解答 Nov 25 '14 在 6:02 AM

1

It seems to be a bug. UIs might be drawn in order in hierarchy among the same ZOrdered UIs. But in UE4 engine codes, I found codes not to preserve the order in hierarchy while trying to sort by ZOrder.

The codes are at SConstraintCanvas.cpp - 79 lines. (SConstraintCanvas::OnArrangeChildren, Engine Ver. 4.8.2)

SlotOrder.Sort(FSortSlotsByZOrder());

This line should be corrected to below.

SlotOrder.StableSort(FSortSlotsByZOrder());

After I rebuilt the engine, it worked in the way I thought.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值