public void AddBlock() { RichEditBlock block = new RichEditBlock(contentPanel, rectTransform.rect.width, LineSpacing); blockList.Add(block); block.LayoutGroup.spacing = LineSpacing; UpdateHeightForNewBlock(block); currentBlock = block; }
private void UpdateHeightForNewBlock(RichEditBlock block) { if (currentBlock != null) { previousHeight += currentBlock.LayoutElement.preferredHeight + BlockSpacing; } contentPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, previousHeight + block.LayoutElement.preferredHeight); }
public void Clear() { transform.DetachChildren(); foreach(var block in blockList) { Destroy(block.GameObject); } blockList.Clear(); previousHeight = 0; currentBlock = null; }