public void Init (SomeClass evt)
{
the_thing = evt;
time_label.text = the_thing.event_time.ToString();
distance_label.text = the_thing.Distance();
description.text = the_thing.description;
// time_label is anchored to the top of background_sprite
time_label.UpdateAnchors();
time_label.Update();
// distance_label is anchored to the bottom of time_label
distance_label.UpdateAnchors();
distance_label.Update();
// description is anchored to the bottom of distance_label
description.UpdateAnchors();
description.Update();
StartCoroutine(ResizeBG());
}
IEnumerator ResizeBG()
{
yield return new WaitForEndOfFrame
(); // Gets the local position at the bottom of the final text item to determine the background height.
int height_val = Mathf.RoundToInt(-description.GetSides(transform)[3].y);
background_sprite.height = height_val;
}