Author Topic: Refreshing/repositionning dynamic items in grid  (Read 3598 times)

poulpator

  • Guest
Refreshing/repositionning dynamic items in grid
« on: June 06, 2012, 06:58:51 AM »
Hi there,
A new question about a grid filled with dynamic components, it's quite popular these days :P
So I fill this grid with items, and suddenly I want to empty it and fill it with new items, and reset the items/panel position.
What I'm doing (after removing/adding components) is:
m_UIDraggablePanel.ResetPosition();
m_UIGrid.repositionNow = true;
Seems quite clean and simple but it does not work, I guess I have something wrong with the timing. My solution for now is to set another boolean "NeedReposition" to true, and in the update do
if (NeedReposition)
    ScriptUIGrid.repositionNow = true;
This one works fine but is kinda inelegant, does someone know a better way to do that...?
Thanks!


joreldraw

  • Guest
Re: Refreshing/repositionning dynamic items in grid
« Reply #1 on: June 06, 2012, 07:46:24 AM »
Why unellegant ?

This is called Flag!. I use this system too and i like this.
I have my flag class to set some events.

Another way "more ellegant" is make your own event and add your code in "void YourEvent" but is a little more complex.

poulpator

  • Guest
Re: Refreshing/repositionning dynamic items in grid
« Reply #2 on: June 08, 2012, 12:45:23 PM »
Having one flag is not inelegant, but in my case I use one flag that sets another flag that calls a function. I'm pretty sure I have to do this because I do not call the right functions at the right moment. Then again I found a way around it so it's not a big issue, but my guess is that there is some fonction I could/should call that would avoid this.

Skared Creations

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
    • Skared Creations
Re: Refreshing/repositionning dynamic items in grid
« Reply #3 on: June 08, 2012, 01:37:13 PM »
mh.. I call directly the UIGrid.Reposition method, because repositionNow is a flag checked inside Update so hopefully calling directly the method without waiting the next Update should/could be faster.
Skared Creations
Game Development Studio
http://skaredcreations.com