I am trying to dynamically create dynamic buttons by adding text to a label that is set to Resize freely, and then adding a box collider, but I cannot find a way to do this in the same frame. How can I force the label to recalculate its width immediately before creating the collider? I have tried MarkAsChanged and SetDirty, but they are not updating the width field.
theLabel.overflowMethod = UILabel.Overflow.ResizeFreely;
theLabel.text = theCategory;
theCollider = this.gameObject.AddComponent<BoxCollider>();
theCollider
.size = new Vector3
(theLabel
.width + 100, theLabel
.height, 1f
);