public override void Update() { base.Update(); if (label.Font != null && label.Font.IsSDFCapable != previousSDFState) { label.RefreshLayout(); previousSDFState = label.Font.IsSDFCapable; } float width = checkTextureSize.x + checkTextHorzOffset + label.Size.x; float height = Mathf.Max(checkTextureSize.y, label.Size.y); Size = new Vector2(width, height); }
public override void Draw() { base.Draw(); if (verticalScrollMode == VerticalScrollModes.EntryWise) { float x = 0, y = 0; float currentLine = 0; for (int i = 0; i < listItems.Count; i++) { TextLabel label = listItems[i].textLabel; if (currentLine < scrollIndex || currentLine >= scrollIndex + rowsDisplayed) { currentLine += label.NumTextLines; continue; } currentLine += label.NumTextLines; label.StartCharacterIndex = horizontalScrollIndex; label.RefreshLayout(); if (i == selectedIndex) { label.TextColor = listItems[i].selectedTextColor; label.ShadowPosition = selectedShadowPosition; label.ShadowColor = listItems[i].selectedShadowColor; } else { label.TextColor = listItems[i].textColor; label.ShadowPosition = shadowPosition; label.ShadowColor = listItems[i].shadowColor; } label.Position = new Vector2(x, y); label.Draw(); y += label.TextHeight + rowSpacing; } } else if (verticalScrollMode == VerticalScrollModes.PixelWise) { int x = 0; int y = -scrollIndex; for (int i = 0; i < listItems.Count; i++) { TextLabel label = listItems[i].textLabel; if (y + label.TextHeight < 0 || y >= this.Size.y) { y += label.TextHeight + rowSpacing; continue; } if (horizontalScrollMode == HorizontalScrollModes.CharWise) { label.StartCharacterIndex = horizontalScrollIndex; } else if (horizontalScrollMode == HorizontalScrollModes.PixelWise) { x = -horizontalScrollIndex; } label.RefreshLayout(); if (i == selectedIndex) { label.TextColor = listItems[i].selectedTextColor; label.ShadowPosition = selectedShadowPosition; label.ShadowColor = listItems[i].selectedShadowColor; } else { label.TextColor = listItems[i].textColor; label.ShadowPosition = shadowPosition; label.ShadowColor = listItems[i].shadowColor; } label.HorzPixelScrollOffset = x; label.Position = new Vector2(x, y); label.Draw(); y += label.TextHeight + rowSpacing; } } }