2

I am using the GridObjectCollection Script from MRTK to display a number of buttons. I am instantiating the buttons dynamically through a script and place them as children of the GridObjectCollection GameObject. Now you can Update the collection through the UpdateCollection() function. Everything works as expected except the following case:

If i want to display a set of different buttons in the same GridObjectCollection, i destroy all children of the collection and instantiate the new buttons as before and call the UpdateCollection() function. But the collection is not updating properly. The old buttons were destroyed and the new added, but the placement is shifted. If i click the UpdateCollection button in inspector, the collection is correctly updated.

Why UpdateCollection() is not working as expected after modifying the content of the collection?

jules_io
  • 41
  • 5

1 Answers1

2

I just fixed the problem. If the collection is updated in the next frame, the update works as expected. So i am starting a Coroutine and call the update function there.

private IEnumerator InvokeUpdateCollection()
{
    yield return null;
    gridObjectCollection.UpdateCollection();
}
jules_io
  • 41
  • 5