Author Topic: Clearing UITable immediately  (Read 2387 times)

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Clearing UITable immediately
« on: June 23, 2014, 12:27:36 AM »
I have a SV with a table that's being dynamically populated again and again with new info with fresh data.

I need a way to immediately clear out all of the data from the table when fresh data comes in.  Looking at the UiTable code, there's not an immediate way of clearing the mChildren list.  Seems only on the next update.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clearing UITable immediately
« Reply #1 on: June 24, 2014, 02:17:54 AM »
GetComponent<UITable>().children.Clear();

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Clearing UITable immediately
« Reply #2 on: June 24, 2014, 05:17:29 AM »
Ah, seems like the problem is that I was testing using Destroy and it didn't work.

Had to do destroyImmediately for the table to recognize that there are no more children.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clearing UITable immediately
« Reply #3 on: June 25, 2014, 04:43:41 AM »
Object.Destroy() doesn't remove children. It's a delayed process. DestroyImmediate should only be used at edit time as per Unity's docs.

Use NGUITools.Destroy instead.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Clearing UITable immediately
« Reply #4 on: June 25, 2014, 12:32:31 PM »
Thanks for this Tip.