I’ve got a couple of elements being instantiated through code (prefabs). There’s a parent vertical layout group, and a couple of children to this. For some strange reason though, none of the children are displayed. In the edit view you can see them as red crosses in weird places. However, as soon as I add another element to this vertical layout group, they will suddenly snap to their correct positions and display as expected.
Now, I could create some code adding an element after some time to the layout group, but that feels like such a hack (edit: tried it and that works). I have no idea why Unity behaves this way. I couldn’t find any documentation stating you have to refresh the vertical layout group or whatever.
Any idea what I’m doing wrong here?
edit:
Tried waiting for fixed update in children before adding them to vertical layout group. Didn’t work. However waiting for 2 fixed update did. So I suppose it has something to do with the layout group not being fully initialized or something when instantiated.
edit:
The UI and scripts work fine (without timeouts) when alone in scene. So it has something to do with the complexity of the scene. Can’t risk having the UI not initialized, so I’m going with the solution of adding and removing an element to the vertical layout group a few couple of times for some seconds during initialization.
Well I finally managed to reproduce this 100% of the time it in a small project. I submitted a bug report but I have no idea how to view it. I didn’t get a number or anything.
I reported this on thursday, with some further details.
Try replicating some of the things I was getting…dragging children into the container at runtime, they show up, but if you drag them into one of the bugged children, then back out, they stay broken even if you drag them out of the container altogether.
I know how you feel, it’s frustrating - “I can’t be the only one?” We’ve not been able to upgrade past 4.6.1p1, and we’re running out of “little things” to do.