A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'UIElements' started by wang37921, Jan 15, 2019.
item is absolute position type,
how to set its width and height fillup its parent container.
StretchToParentSize(); is likely what you're looking for. But - you may have to use it with a callback as it sometimes fails for me, perhaps because layout hasn't yet been calculated.
ve.style.width = 100;
ve.style.height = 100;
ve.StretchToParentSize();// actually, it is setting style.positionLeft and so on
if assign the style.width or style.height value, StretchToParentSize() will not take effect.
found: set ve.layout will change PositionType to manual, it will invalidate style position and flex layout system.
As you correctly diagnosed, the preferred way to have the child fill its parent is to zero out the positionLeft|Right|Top|Bottom, as done in the StretchToParentSize method. By setting width/height, we'd actually submit conflicting constraints to the layout system
thx, i am greens on the web layout system.
i try many times, found that conflict.
must use left,right,top,bottom with absolute type together.
or, left, right, width,height.
switch use them must invoke ResetPositionPorperties first.
But there also include ve.layout, ve.transform...i was confuse...
maybe more details document be friendly
yes, we're working on more complete documentation, this will improve as UIElements matures
Hey all - so i've found 2 good methods for fill like this (that have not been mentioned)