Author Topic: Scroll views issue since update to 3.5.7  (Read 8582 times)

Dethanos

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Scroll views issue since update to 3.5.7
« on: April 17, 2014, 01:45:07 PM »
Good evening,

I have been using the scroll view to allow the gamer to scroll through a fair amount of data containing labels, tables, grids, sprites the whole lot and all was working fine. I then updated from 3.5.6 to 3.5.7 and everything has started behaving very strangely.

And when I say strangely I mean the width decreasing to 0 and the widget running off the side of the screen until I select it in the Hierarchy (that seems to stop it moving for some reason).

To align all of my items within the ScrollView I set anchors and their appropriate absolutes, targets and updateAnchors In Code, and I have narrowed it down to this being the issue.

Basically I did what we all do and took everything out with the exception of one label with its anchors set in code, and lo and behold it exhibited the same weird issue. Take out the Anchors being set in the code and everything is stationary (not in the right place, but at least it aint running away).

Is this something that has changed? Should I not be doing it like this? Or is it a legitimate bug?

Cheers,

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll views issue since update to 3.5.7
« Reply #1 on: April 18, 2014, 02:06:51 PM »
Why are you anchoring things inside your scroll view? Scroll view's content is fluid, it moves around. It can't move if it's anchored.

Dethanos

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Scroll views issue since update to 3.5.7
« Reply #2 on: April 18, 2014, 05:27:37 PM »
The first item is only anchored (using advanced) to the right side of the scroll view only (that's the label I was referring to above) in code, If i do this from the editor it does not run off.

In other instances I anchor the items to the item above it to ensure everything stays in line, the top one is not linked to the top or anything like that, the first ones position is set using local position.

I was mainly wondering as this was all behaving in 3.5.6, what has changed? will it change back or will I need to find a new way of doing this, im only hesitant as it took me a fair while to get everything aligned correctly.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll views issue since update to 3.5.7
« Reply #3 on: April 18, 2014, 05:42:03 PM »
Quote
In other instances I anchor the items to the item above it to ensure everything stays in line,
Technically, that's what UITable is for. It's also what I use in the Quest Log example.

I can't think of anything that changed from 3.5.6 to 3.5.7 that would affect it. Make sure the first item is anchored with some padding. If it's anchored to the right-hand side using no padding then there may be an issue with floating point rounding, where some frames it may be inside the scroll view, other times -- outside it.

Dethanos

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Scroll views issue since update to 3.5.7
« Reply #4 on: April 19, 2014, 01:21:35 PM »
Quote
Technically, that's what UITable is for. It's also what I use in the Quest Log example.

Indeed use them all over the shop including in this page, however I did not include them all inside one master table, not quite sure why... will change that.

Also yep, the right is -15 pixels from the scroll view edge, I have absolutly no idea why this would not work when setting things in code and would work when setting it in the editor. (i just tested it again to prove to myself im not going insane.)

Anyway if this is the way its supposed to work (not anchoring to the side of scroll views) and for the past month its just been working by accident, ill have to do it in another way, already got a few ideas.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll views issue since update to 3.5.7
« Reply #5 on: April 19, 2014, 11:15:19 PM »
It should work. I just tried a test with the scroll view example, anchoring the content's top and bottom to the scroll view. It worked as expected.

Dethanos

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Scroll views issue since update to 3.5.7
« Reply #6 on: April 20, 2014, 02:01:09 PM »
This is the code I was using perhaps you can see the error:

  1.         noFleetsDestroyed.leftAnchor.target = ScrollView.GetComponent<UIPanel>().transform;
  2.         noFleetsDestroyed.leftAnchor.absolute = 20;
  3.         noFleetsDestroyed.updateAnchors = UIRect.AnchorUpdate.OnEnable;

This is just the one I was attempting for my new version. (this code makes the noFleetsDestroyed x position continually increase).


Additionally you might wanna check out the tables execute (reposition method) every time i right click Execute items in the table grow in size along their X Axis. (also yep I cannot reproduce this on your quest log example. I have no idea what the differences is between the two of ours and why we are getting such random differences.)
« Last Edit: April 20, 2014, 02:33:17 PM by Dethanos »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll views issue since update to 3.5.7
« Reply #7 on: April 20, 2014, 05:17:02 PM »
You need to call ResetAnchors() and UpdateAnchors() after modifying the anchors via code. Look at UIRect.SetAnchor.

Dethanos

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Scroll views issue since update to 3.5.7
« Reply #8 on: April 20, 2014, 06:13:04 PM »
Right that sorted the issue, really should have waited before ripping out my old version but the new one is better anyway so win win.

Also just on previous point, I have a label anchored (in editor) left aligned and top left pivoted, and when ever I execute the table the label grows along its x axis, however this only appears to occur when the label is on shrink content. I got around this by putting it on ResizeFreely.

Anyway cheers for the help and the prompt responses.