public void AddCell(PropertyDescriptor data) { if (data.PropObject == null) { return; } var go = _itemContainer.CreateGameObject("PropCell"); go.AddComponent <RectTransform>(); var layoutElement = go.AddComponent <LayoutElement>(); layoutElement.preferredHeight = 16; layoutElement.preferredWidth = 70; var contentSizeFitter = go.AddComponent <ContentSizeFitter>(); contentSizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; //go.AddComponent<StackLayoutGroup>(); var cellType = data.Type switch { EPropertyType.Float => typeof(FloatPropCell), EPropertyType.Bool => typeof(BoolPropCell), EPropertyType.Color => typeof(ColorPropCell), EPropertyType.Texture => typeof(TexturePropCell), _ => throw new ArgumentOutOfRangeException(nameof(data), "cell type not handled") }; var comp = (BasePropCell)go.AddComponent(cellType); BsmlDecorator.ParseFromResource(comp.ContentLocation, go, comp); comp.SetData(data); _cells.Add(comp); } }