void TreePack()
{
Node root = new Node( new Rect( 0,
0,
width,
height ) );
foreach ( Element el in elements ) {
Vector2? pos = root.Insert (el);
if (pos != null) {
el.coord[0] = (int)pos.Value.x;
el.coord[1] = (int)pos.Value.y;
}
else {
// log error but continue processing other elements
Debug.LogError("Failed to layout element " + el.texture.name);
}
}
}