Out of an array I instantiate Draggable Content one by one and parent them under a grid. The grid is under the Draggable Panel.
When I do this process by hand the draggable content lines up properly and preserves its dimensions.
When I do it in Start however the elements are about 100x their size.
It seems I need to trigger some calculation by hand to resize these elements properly, I tried grid.Reposition and it doesn't change a thing.
What's the secret sauce ?
[System.Serializable]
public class Decal
{
public string name;
public Texture decal;
public DraggableButton draggableButton;
}
public List<Decal> decals;
public DraggableButton buttonPrefab;
public UIGrid gridParent;
void Start ()
{
for (int i=0; i<decals.Count; i++) {
Decal d = decals [i];
GameObject dg = (GameObject)Instantiate (buttonPrefab.gameObject);
dg.name = "item " + i.ToString ();
dg.transform.parent = gridParent.transform;
d.draggableButton = dg.GetComponent<DraggableButton> ();
// init the butten
d.draggableButton.SetDecal (d.decal);
d.draggableButton.SetName (d.name);
d.draggableButton.SetCallBack (gameObject, "ChooseDecal");
}
gridParent.Reposition ();
}
PS: amazing customer service !