1
Support / Re: UI Grid Creation at Runtime (tk2dUI AddLayout at runtime)
« on: May 11, 2015, 05:40:19 pm »
Have a similar issue with tk2dUILayoutContainerSizer, comes out with stack overflow!
What I've done:-
// Step 1 - Create blank scene
// Step 2 - Drag in "BasicButton" (with layout)
// Step 3 - Create empty game object and add tk2dUILayoutContainerSizer
// Step 4 - create a script to instantiate multiple "BasicButton" from the scene, then adding it to the tk2dUILayoutContainerSizer
// Script
public tk2dUILayout prefabItem;
void Start(){
tk2dUILayout myLayout = Instantiate<tk2dUILayout>(prefabItem);
tk2dUILayoutContainerSizer sizer = this.GetComponent<tk2dUILayoutContainerSizer>();
foreach (tk2dUILayoutItem item in myLayout.layoutItems) {
sizer.AddLayout(myLayout, item); <---- produces stack overflow
}
}
What I've done:-
// Step 1 - Create blank scene
// Step 2 - Drag in "BasicButton" (with layout)
// Step 3 - Create empty game object and add tk2dUILayoutContainerSizer
// Step 4 - create a script to instantiate multiple "BasicButton" from the scene, then adding it to the tk2dUILayoutContainerSizer
// Script
public tk2dUILayout prefabItem;
void Start(){
tk2dUILayout myLayout = Instantiate<tk2dUILayout>(prefabItem);
tk2dUILayoutContainerSizer sizer = this.GetComponent<tk2dUILayoutContainerSizer>();
foreach (tk2dUILayoutItem item in myLayout.layoutItems) {
sizer.AddLayout(myLayout, item); <---- produces stack overflow
}
}