- Home /
Question by
bstoev · Jun 12, 2017 at 08:59 AM ·
canvasuser interfaceanchorpivot-point
Is position used instead of pivot when anchors are different from the default?
Hello, in my test scene with Canvas UI, I have one big square Image object in the center and a smaller child object inside it at its middle.
I am displaying a debug sprite at the position of the pivot
of the child which I get like this:
Vector2 GetPivotReferencePoint()
{
Vector2 pivot = rectTransform.pivot;
pivot -= new Vector2(0.5f, 0.5f);
float sizeX = rectTransform.sizeDelta.x * rectTransform.lossyScale.x;
float sizeY = rectTransform.sizeDelta.y * rectTransform.lossyScale.y;
pivot.x *= sizeX;
pivot.y *= sizeY;
return pivot;
}
It works normally when both anchors are set to 0.5
However when I change the anchors, it seems that when I rotate the Image, it doesn't rotate around where the pivot
sprite is anymore, it rotates around where localPosition
is.
Does this mean the pivot isn't used when anchors are set?
Comment