Author Topic: Focus on an object in ScrollView panel  (Read 7074 times)

TypoStraw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 19
    • View Profile
Focus on an object in ScrollView panel
« on: March 22, 2014, 09:01:48 AM »
I'm working on a level browsing system, but have some problems getting it to focus on the selected section.

Collapsed: http://i.imgur.com/4DIVHHM.png
Expanded: http://i.imgur.com/ybkzjsB.png

This was made like the quest log example, so the levels get expanded under the act button using a TweenScale.

When you click on the act button, it should expand and the button should be placed at the top (like in the screenshots), any other expanded acts should collapse (I got this part working just fine).
I had a look at your UICenterOnClick script, but there are 2 problems with this script. First of all it will center on the object, instead of placing it at the top.
I tried to bypass this simply by adding 175f to the offset.y, before starting the spring tween.

This does the job when the spring strength is low, since the expand tween will end before the spring tween, but is simply too slow.. When setting the strength to a higher value, the spring tween will end slightly before the other tween and it will not be placed all the way at the top.

Any idea of how to handle this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Focus on an object in ScrollView panel
« Reply #1 on: March 22, 2014, 03:31:09 PM »
What is it you're trying to focus on in there? You have a vertical list of buttons in one pic, and then an entire grid in another pic. What's there to focus on in the 2nd one?

TypoStraw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Focus on an object in ScrollView panel
« Reply #2 on: March 22, 2014, 04:09:18 PM »
The grid is expanded from below the button, so you can scroll down and find the other act buttons. It is exactly like the quest log example, just instead of a description of the quest, it is a grid of level selection buttons.

When expanded, the pressed button should be set at the top, and thereby making it possible to view the entire expanded act.
If I press a button further down in the list instead of act 1, it will be displayed like this: http://i.imgur.com/V3L3UBv.png - where you can only see 2 out of 3 rows, and the selected act button is in the middle instead of at the top.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Focus on an object in ScrollView panel
« Reply #3 on: March 23, 2014, 02:47:04 AM »
The quest log example doesn't use UICenterOnChild or UICenterOnClick. Any particular reason you need it to begin with?

TypoStraw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Focus on an object in ScrollView panel
« Reply #4 on: March 23, 2014, 04:40:55 AM »
Had forgotten about that.. Then like the quest log, except that part :)

We want it added because it feels sort of incomplete. If you click the button to expand it, you would expect that it would not be possible to expand into an area you can't even see. If you click the button, you want to know more about that specific act, not all the others. With the focus it provides a quick and easy overview with just 1 single tap.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Focus on an object in ScrollView panel
« Reply #5 on: March 24, 2014, 06:34:12 PM »
I would suggest you just write a script for your buttons that do a SpringPosition.Begin to the target position instead of using UICenterOnChild. UICenterOnClick does this if you don't have a center on child script, but it assumes that you want to center on the clicked object -- and in your case you would want to center on the content instead of the clicked object (which is a header in your case).