Author Topic: Sprites disappear when moving them via code  (Read 22281 times)

arkon3

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 71
    • View Profile
Sprites disappear when moving them via code
« on: August 27, 2015, 08:22:16 PM »
I have a UIPanel set to soft clip with a scroll view attached. I then have 20 game objects as children of this, basically sprites with a label attached, like a list view. the clipped panel is big enough to show 20 of them and the user then scrolls the view up an I in code just move the 1st child (Sprite and Label) to the bottom of the children.

This works about 70% of the time but a few of the moved children have the sprite not visible even though it's all moved to its new location ok. if in the editor I click the enable box on the sprite twice it now magically reappears.

I move the sprite just by changing it's .localposition

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sprites disappear when moving them via code
« Reply #1 on: August 30, 2015, 12:11:09 PM »
Have you seen the UIWrapContent script shown in the last example that comes with NGUI? It does what you're trying to do already -- reuses a certain number of items to create a much longer scroll view. As for your issue, make sure your panel's "Is Static" flag is not checked.

arkon3

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 71
    • View Profile
Re: Sprites disappear when moving them via code
« Reply #2 on: September 08, 2015, 09:00:09 AM »
Cool, static ticked was the cause. I'll try the wrap thing and see how I get on.