- Home /
Store position over scrolled panel
Hi I have a few buttons over a scrolled panel. NOT using the layout. they each have its own position over the panel.
1) i take one of the elements out to another panel.
2) i move the panel up
3) I snap the element out of the other panel, it is automatically snaps (in lerp) Back to its old position
Problem: the old position is "floating" over the originaly moved panel, the button return to a poisition which is not mover another element.
What is the right way to calculate the element original position to change after i move the panel up / down ?
thanks
I can ofcourse place a null that is also a child of he scrolled panel and have the element return to this null, that null will be moved with the panel, but looking for better solution.
Answer by Harardin · Dec 12, 2016 at 11:24 AM
You can try to store the new current position via Update function.
Here are some excample for you:
float curCoordinatesX = CurScroller.GetComponent<RectTransform>().anchoredPosition3D.x;
float curCoordinatesY = CurScroller.GetComponent<RectTransform>().anchoredPosition3D.y;
float curCoordinatesZ = CurScroller.GetComponent<RectTransform>().anchoredPosition3D.z;