Author Topic: Scroll View doubts  (Read 2952 times)

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Scroll View doubts
« on: July 14, 2014, 05:13:32 AM »
After having read carefully the video tutorials of this component, I can make several things, but still have 2 doubts. I'll try to be as detailed as possible.
  • I have a scroll view and inside some buttons. If I use unified anchors with the buttons, the scroll view stops to drag, since positions of the buttons seem to be fixed. In this case I used anchors related to UIRoot. However, if I don't use unified anchors, when I move from 16:9 to 4:3 the buttons are no longer aligned to the left as I wish.
    How should I proceed?
  • If I add the UICenterOnChild script to my scroll view, the buttons are auto-centered. What I need is to autoalign to the left (with a little separation to the left) like in many games.How should I proceed?
Thank you.
Game developer on Casual Arena.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll View doubts
« Reply #1 on: July 15, 2014, 12:24:38 AM »
1. You can't scroll things that are anchored for obvious reasons. If you want buttons to be aligned on one axis (for example horizontally) and scrolled on the other axis (for example vertically), then use advanced anchoring and set left and right, but don't set top and bottom anchors.

2. It wouldn't be UICenterOnChild anymore then. Note that the scroll view is centered on game objects underneath the UICenterOnChild script. You don't have to use a center pivot on those objects. If you have this:

UIScrollView
- UICenterOnChild
-- Item 1
-- Item 2
-- Item 3

Then you can change it to be:

UIScrollView
- UICenterOnChild
-- Offset 1
--- Item 1
-- Offset 2
--- Item 2
-- Offset 3
--- Item 3

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Re: Scroll View doubts
« Reply #2 on: July 15, 2014, 05:57:08 AM »
Thank you for your answer.
I was able to fix the center issue with your 2nd suggestion.

I still have 2 unfixed problems (maybe I'm just not good enough):
  • Without unified anchor, I don't know how to auto-align the first button on the left on 4:3 resolution (I'm building on 16:9 now). I did it with unified anchor with respect to UIRoot, but now, how should I do it? I still and also need to have the scroll view. See image 1 for example.
  • I want to "center" on the left, that's perfect. But also avoiding moving completely to the left on the last elements (see image 2). All games I see on the market align to the left but with a limit on the right to avoid having a big gap and keeping having 3-4 buttons always visible. How can I do it?

Thank you.
Game developer on Casual Arena.

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Re: Scroll View doubts
« Reply #3 on: July 15, 2014, 06:01:23 AM »
By the way, I need all that for any resolution between 4:3 and 16:9.
Maybe the only solution is by programming. If so, it's ok, I'll programme it, but maybe it's just that I don't know how to set up NGUI properly.
Game developer on Casual Arena.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Scroll View doubts
« Reply #4 on: July 15, 2014, 08:10:12 AM »
I had previously asked to do the same thing. It looks like there is a real need for this functionality. Perhaps it's a good time to build this into NGUI because this issue will come up again as more people are trying to replicate how most scrollviews work.

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Re: Scroll View doubts
« Reply #5 on: July 15, 2014, 08:12:48 AM »
I agree with you wallabie.
I am sure that it can be done with programming, but I also guess there should be a way to do with some kind of trick with current NGUI, like you can use "offset gameObject for aligning on the left". Maybe admins can help us :)
Game developer on Casual Arena.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll View doubts
« Reply #6 on: July 15, 2014, 09:46:37 PM »
@Tatanan: My answer to your #1 is my #1. Don't use a unified anchor. Use an advanced anchor, anchored only on the axes that aren't being scrolled. Unless you mean aligning the button horizontally, as well as have the scroll view scroll horizontally? If so, UpdatePosition() on the scroll view (or ResetPosition()), provided you chose the Content Origin to be on the left-hand side.

In regards to your #2, that's how the UICenterOnChild script works. It centers on the child (with your offset). If you wanted to restrict it to not scroll past the edges, then it wouldn't be centering anymore at all, would it? How would you even show that your "centered" item is changing if it's locked to not move anymore past a certain point? It sounds like you shouldn't be using the UICenterOnChild script anymore at this point. You need too much custom functionality from it. You will want to write your own script.