- Home /
How can I "detect" if a UI element is on certain position?
Here's the case: I want to make a vertical scroll menu that will "select/highlight" a button/panel and change the color of other elements while also show some elements that originally hidden.
As I depicted in the following image, I want:
1. A certain title (Title-n) is selected/highlighted as default.
2. Title2 is selected/highlighted when 80% of Title1 is not visible anymore (menu is scrolled). OR any Title-n is selected/highlighted when its position is on certain number (second one-fourth of the visible menu if divided vertically). I don't know the logic to achieve this.
3. When a Title-n is selected/highlighted, it shows its corresponding description and button (in the image: Title2 is highlighted, then it shows Title2-description and Go button)
4. Any Title-n that is not highlighted will be desaturated (grey) and not show its description nor button.
How can I make something like this?
Answer by dakshesh1010 · Oct 31, 2017 at 09:20 AM
Use onValueChanged from ScrollRect Component. Use that in combination with verticalNormalizedPos to know where the scroll value is. You can first debug how scroll's normalized positions are changed.
Depending on vertical normalized position, you can highlight the corresponding element in the content, and disable the rest.