1
\$\begingroup\$

I have a map in my game the user can interact with. I am using Unity UGUI ScrollRect to let the user move the map on the screen. Only one area of the map is visible at a time and you can scroll it to get to the desired level (just like in King games). The content of this map system is an Image and level buttons which are all children of the map image.

I want my ScrollRect to point to the current active level when the map loads. For example, if I am on level 30 then on loading the map level the content of the ScrollRect should be on the portion of the map where level 30 is.

I can't find anything regarding managing ScrollRect's content position

\$\endgroup\$
1
\$\begingroup\$

I believe you're looking for the scrolling position parameters for ScrollRect

You would need to find your level marker's position in it's parent (the ScrollRect) and then convert it to a normalized position (divide position by the parents width/height). From there you can set the horizontal and vertical normalized position to the desired values.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.