- Home /
Help with finding normalized position of buttons in scroll rect?
Hello all,
I have a scroll rect with an image which has a height of 5000. The image in the scroll rect has 20 children button items lined up vertically. I would like to find out the vertical normalized position of each of the 20 children relative to the parent image object in the scroll rect. Can anyone help wiith generating code which would do this? An example would be that button item ten (10) is in the middle of the image, and so the vertical normalized position would be 0.5f.
I'm trying this - but it doesn't work to give me a centered position as the $$anonymous$$ and max values gives a bad offset. Is there a way to do it with the height of the buttons in relation to where they are in the parent?
public float max ;
public float $$anonymous$$ ;
public float score;
number = image.GetComponent<RectTransform>().anchoredPosition.y;
normalizedposition = (number - $$anonymous$$) / (max - $$anonymous$$);
Your answer
Follow this Question
Related Questions
How to set position in ScrollView? 1 Answer
How to expand scrollRect content without having normalized position snap back to 1 (ScrollJacking) 0 Answers
Scrollable rect containing GUIText/Label 1 Answer
Scrollview is positioning things incorrectly 1 Answer
Player controls for scrolling horizontally/vertically? 0 Answers