Rating
A Rating is a row of stars that shows and sets a rating from 0 to MaxValue. Its value is a float.


<UIToolbox.Rating label="Rating" value="3.5" allow-half="true" />
<UIToolbox.Rating value="4.5" read-only="true" symbol="♥" />
| Member | Description |
|---|---|
MaxValue (max-value) |
The number of stars (5). The smallest is 1. Fewer stars clamp the value. |
AllowHalf (allow-half) |
A click on the left half of a star, and the keys, set half steps. |
ReadOnly (read-only) |
Shows the rating and ignores the pointer and the keys. |
Symbol (symbol) |
The text of one star (★). Any glyph in the font works. |
Image (image) |
An image for each star instead of Symbol: a texture, sprite or vector image. The USS tint colors the empty and the filled stars, so use a white image. |
- The value always takes half steps and is clamped to 0 to
MaxValue. WithoutAllowHalf, a value such as 3.5 still shows as three and a half stars, so a read-only average works. - The stars under the pointer preview the rating. A click sets it and gives focus. A click on the current rating clears it to 0.
- Left and Right (the arrow keys or the gamepad) move to the next step. Home and End set 0 and
MaxValue. Left and Right do not move focus.
In the examples


Styling
| Class | Element |
|---|---|
tb-rating |
The field. |
tb-rating__star |
One star, in the muted color. With image, -unity-background-image-tint-color colors the image. |
tb-rating__fill |
The clipped copy on top of a star. Its width shows a whole, half or empty star. Its label uses the warning color and takes the size and font size of tb-rating__star. |
tb-rating--read-only |
On the field when read-only is set. |
tb-rating--preview |
On the field while the pointer previews a rating. |
The RatingDemo scene shows the review of a quest, the read-only averages of a market that a vote moves, hearts, dots and image stars, and a custom look.
SVG: Image is a Background. An SVG imported as a VectorImage works as well as a texture. See Pictures: PNG or SVG.