Author Topic: Scrollview glitching when anchored  (Read 13446 times)

abclive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Scrollview glitching when anchored
« on: July 17, 2014, 07:36:44 AM »
Hello everyone !

I've found a weird bug when using Scrollview. I wanted it to be width responsive, so I made two anchors refreshed onUpdate. One based on the left side and the other one in the right side. But as soon as my Scrollview is anchored to them it's get super glitchy. I cannot move it anymore since he goes in the wrong way and with an exponential speed (and in addition to that item still have a normal behaviour). But the real big problem is that on every frame, the Scrollview move down by itself. Even in the editor when I tweak a value for example.

Here is a video of the glitch :
https://www.youtube.com/watch?v=LnEP8bLuQjM

And a screen of my hierarchy:


I'm using Unity Free 3.5.0f6 and the latest version of NGUI Pro.
PS: If I put the Anchor refresh OnEnable it's only fix the problem on play.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview glitching when anchored
« Reply #1 on: July 18, 2014, 04:40:21 AM »
What's L Anchor, R Anchor etc? That's what you anchored your scroll view to... where are they located? They must not be children of your scroll view. My guess is that's where you put them, so the scroll view is anchored to its moving child, which is all kinds of weird.

abclive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview glitching when anchored
« Reply #2 on: July 19, 2014, 01:48:46 AM »
L and R anchor are respectively Left and Right anchor. They are child of UIRoot only and they have no childrens.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Scrollview glitching when anchored
« Reply #3 on: July 19, 2014, 07:51:32 AM »
Could you share your hierarchy?

It seems like you have both your scrollview anchored, but also a UIWidget inside the scrollview anchored to something outside the clipped area. This can bring problems because the scrollview works by moving the sub-objects inside it by position, which will potentially fight with the anchor which then tries to move it back.

abclive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview glitching when anchored
« Reply #4 on: July 20, 2014, 10:47:46 AM »

Here is my hierarchy, I highlighted the things that are anchored. I anchored them in advanced mode for have a responsive scroll view. None of the items in the grid are anchored nor the grid.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Scrollview glitching when anchored
« Reply #5 on: July 20, 2014, 04:15:18 PM »
Yeah, so I think the problem is that the ScrollView itself is anchored, which will make the anchors and scrolling fight with each other on where it should be positioned. Have you tried setting the scrollView's anchor to be OnEnable? Then it should position it when you start, then the scrollView takes over positioning afterwards.

abclive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview glitching when anchored
« Reply #6 on: July 21, 2014, 03:41:54 AM »
Like I said at the end of my first post yes I tried using OnEnable and yes it fix only the game part. The editor bug is still present. And I don't really understand why I can't anchor my scroll view and why there is a conflict ? How do I manage to have a responsive layout then ?

andreyd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: Scrollview glitching when anchored
« Reply #7 on: July 21, 2014, 09:54:39 AM »
Instead of anchoring your UIScrollView, create an empty UIWidget as a it's parent and anchor it.

abclive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview glitching when anchored
« Reply #8 on: July 21, 2014, 11:52:46 AM »
But does the ScrollView will follow the guide from the parent ?

andreyd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: Scrollview glitching when anchored
« Reply #9 on: July 21, 2014, 02:08:53 PM »
What do you mean by the guide? If you are talking about relative position then yes, it should.

abclive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview glitching when anchored
« Reply #10 on: July 21, 2014, 03:49:13 PM »
Thanks for the answer. I just want the scrollview width to fit the screen width.

abclive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview glitching when anchored
« Reply #11 on: July 23, 2014, 06:51:17 AM »
Still have no clue on how to fix this bug. Can anyone try to reproduce it ?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Scrollview glitching when anchored
« Reply #12 on: July 23, 2014, 01:14:16 PM »
Instead of anchoring both scrollview and weapon Selection to L anchor and R anchor, have Weapon Selection anchor to L/R anchor and have scrollview anchor to weapon selection instead.

That ought to fix your problem.

I did a similar thing in the example 14 Endless scrollview that comes with NGUI, to make the third scroll fill the window, while the window was anchored to UIRoot to make it full screen, and that works just fine, even when I resize the game view.

abclive

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview glitching when anchored
« Reply #13 on: July 23, 2014, 03:58:41 PM »
I will try that ASAP thanks !