This code leads to proper flexbox
var _text = GameObject.AddComponent<Text>();
var fitter = GameObject.AddComponent<ContentSizeFitter>();
fitter.verticalFit = fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
this.GameObject.AddComponent<FlexLayout>(); // <----- added after creating the text.
this code leads to nothing. flexbox has no effect on the _text and its siblings.
this.GameObject.AddComponent<FlexLayout>(); // <----- added before creating the text.
var _text = GameObject.AddComponent<Text>();
var fitter = GameObject.AddComponent<ContentSizeFitter>();
fitter.verticalFit = fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
This code leads to proper flexbox
this code leads to nothing. flexbox has no effect on the _text and its siblings.