Author Topic: ScrollView-->Grid-->Widget-->Sprite Positioning error  (Read 6352 times)

Quarkism

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
ScrollView-->Grid-->Widget-->Sprite Positioning error
« on: March 24, 2014, 05:47:36 PM »
Gif of the error
http://i.imgur.com/sH4S4Bh.gif

So I have a multiplayer game lobby. When a player joins the game a new item (A widget placed inside grid inside a scroll view) is added to the listing. When this happens the portrait, rank, and lag sprites for the item are positioned incorrectly (offset to the left) on the host. It works fine for the client instance (oddly). When I tab to scene view the sprites are magically aligned correctly. When I tab back to game view the issue is gone.

I'm not sure what to do to fix this. Is there a message I can push to my child objects or the scroll view to make them snap into place (for the time being)?
« Last Edit: March 24, 2014, 06:13:34 PM by Quarkism »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ScrollView-->Grid-->Widget-->Sprite Positioning error
« Reply #1 on: March 24, 2014, 06:31:13 PM »
What version of NGUI are you using here, and is the UIGrid the only method of positioning you're using or do you have something anchored? UIGrid's Reposition() function should do the job if it's the only thing you have.

Quarkism

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: ScrollView-->Grid-->Widget-->Sprite Positioning error
« Reply #2 on: March 24, 2014, 07:38:48 PM »
What version of NGUI are you using here, and is the UIGrid the only method of positioning you're using or do you have something anchored? UIGrid's Reposition() function should do the job if it's the only thing you have.

3.5.5

The scroll is anchored
The grid inside the scroll is not anchored
The item (sprite) is anchored to the scroll (Advanced left/right binding only)
The pictures inside the item (this is where the problem is) are anchored to the item

I am calling UIGrid.Reposition() after I add the items to the grid.

I am calling it 1 frame after the items have been added.

This is a strange bug... being that it fixes itself If I change to the scene tab or activate/deactivate the object.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ScrollView-->Grid-->Widget-->Sprite Positioning error
« Reply #3 on: March 26, 2014, 03:10:53 AM »
Don't hide your game view behind your scene view. When the game view is hidden, there is no way to determine its size. It's an issue in Unity.