Author Topic: Move ScrollView only if the child is out of the view  (Read 2485 times)

Krzycho

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Move ScrollView only if the child is out of the view
« on: November 19, 2015, 03:46:27 AM »
I'm creating some gamepad controlled gui - some grid base panel with items. I'm using ScrollView and UICenterOnChild.CenterOn() for centering content. The prolem is, that I don't really want to center it every single step, but only scroll if the selected item is out of the clipping panel - so to scroll the items pmy one column up or down, not to the center, to avoid viewing the unnecessary gap over and under the contet . Is it possible to do it easily without custom scrolling script somehow?
(I hope that I was clear enough ;) )

EDIT1:
What I forgot to say is that I use custom scripts for carring user input, so I'm not using any default based input, so I cant use default key navigation ngui systems.

EDIT2:
So what I really need is to check is currently selected item "i" is out of the clipping panel, and then move the view one row up/down.

EDIT3 - SOLVED:
Ok. I've calculated the currently selected object offset and checked if it fits in grid offset bound, and the moved the grid if it was necessary. But I'm still wondering if there was any automatation for that.
« Last Edit: November 19, 2015, 05:41:04 AM by Krzycho »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Move ScrollView only if the child is out of the view
« Reply #1 on: November 25, 2015, 04:49:30 PM »
NGUI has UIPanel.IsVisible functions that can be used to check if a widget is visible, but there is no automatic way to do what you asked.