[SOLVED] How to set the parent group "dirty"?

I have a script that changes anchor and pivot values of some entities inside a group and places them side by side.
The issue I have is that these items are placed wrong, as the pivot never changed (the anchor changes are respected instead).

If I select the parent in the editor, and I touch its position, then all the children get places correctly.

I tried to change and restore by code the position of the parent, but it doesn’t work.

It seems to be a bug. I can’t complete my code without resolving this issue.
Any hint will be much appreciated.

Can you share a link to your project? I’m not sure what’s wrong there

is a private one… I’ll create a repro

1 Like


Open the “Pivot Issue” scene and hit play. You will see that the leftmost square is outside of the view by its half.
Select the parent in the editor, and change the position a bit. Suddenly all the squares go in the correct place.

I see what’s wrong. In your HorizontalAlignment script you are setting values of the pivot / anchors using pc.Vec3#copy. You need to assign the pivot / anchor vectors to the Element’s properties in order to take effect - it won’t work if you are changing their x,y,z values directly.

So change this:


To this:

children[i].element.pivot = pivot;
children[i].element.anchor = anchor;

Yes it makes perfectly sense because pivot and anchor are properties.
I didn’t want to share the same vector with all the elements and I thought that copying the values would have been better than create many new vectors.
Strangely by setting the anchor the same way seemed to work and that confused me more.
Thank you for your great support!

1 Like