Author Topic: UILabel text does not scroll  (Read 3851 times)

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
UILabel text does not scroll
« on: February 05, 2014, 12:07:22 PM »
This probably has a really simple solution. I have a scrollview. I add objects to it that have labels attached. I set the label text within my code. Labels are displayed in the scrollview, but when i scroll, the label text does not move with the scroll. I know that the objects are scrolling because they also have sprites attached.

My hierarchy looks like this:

UIScrollview + UIGrid
    -->UILabel + Collider + UIDrag Scroll View
        -->UISprite

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text does not scroll
« Reply #1 on: February 05, 2014, 02:25:57 PM »
If the labels are children of your scroll view, then they should move just fine. Do sprites move?

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel text does not scroll
« Reply #2 on: February 05, 2014, 02:37:35 PM »
I know right?! The sprites move fine, its just the label text ends up hanging where it is whilst the sprites move. I also have this issue with labels that follow the camera- hierarchy for those is:

-->Sprite
 -->lots of labels

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text does not scroll
« Reply #3 on: February 05, 2014, 02:39:46 PM »
Are they on the correct layer?

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel text does not scroll
« Reply #4 on: February 05, 2014, 02:47:17 PM »
Yep- GUI layer. It's a weird one because it is just a really basic setup.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text does not scroll
« Reply #5 on: February 05, 2014, 02:48:46 PM »
Can you post a pic of what inspector looks like with the UILabel selected?

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel text does not scroll
« Reply #6 on: February 05, 2014, 06:13:09 PM »
Sure, I've added the picture for you. The weirdest thing about the bug is that it doesn't appear to happen every time, rather it intermittently does it. I had the same issue on a label that would follow the mouse, but I managed to fix that by setting all the anchors on all the components to 'none'.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text does not scroll
« Reply #7 on: February 05, 2014, 09:14:22 PM »
First... your UILabel is 150x30, but the box collider is 1500x285? Second... your box collider is not set to "trigger". It should be. How did you add it? Did you use ALT+SHIFT+C or just added it manually?

Lastly... why does your label have a Spring Position script on it? That script causes it to move (or -- in your case likely -- to stay in place). Remove it.

Shemamforash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel text does not scroll
« Reply #8 on: February 06, 2014, 04:30:52 AM »
Hi, the picture I attached was how the button looks at run time. I have attached how the prefab looks. The spring position gets added when the object is instantiated. Clearly the collider is also getting resized as the prefab's box collider is correct. I've also now set the collider to trigger. I built the button using ALT+SHIFT+S, as I didn't know of the ALT+SHIFT+C shortcut.

EDIT: Changing the box collider's trigger seems to have done it. I'm not experiencing any hanging text any more. However my new problem is that when the prefab is added to the scroll view, only some of the prefabs text shows up (meaning only a few labels show text, others don't) unless I close and reopen the window.

EDIT 2: All fixed.
« Last Edit: February 06, 2014, 10:20:17 AM by Shemamforash »