Keeping score
When you score a goal, it should add to your score. If you miss, points are deducted from your score. Scores are displayed in the UI. We will also keep track of your all-time high score, using persistent storage. First, we'll create a UI for the score board.
Current core UI
The score board will be a canvas child of ThrowingGame
:
- With
ThrowingGame
selected in theHierarchy
, create a new UI | Canvas, namedGameCanvas
. - Set its
Render Mode
toWorld Space.
- For its
Rect Transform
, setScale
to (0.015
,0.015
,0.015
). - And
Anchors
: Min (0,5, 0.5
), Max (0.5, 0.5
) andPivot
(0.5
,0.5
). - Then
Position
(-1
,2.5
,1
),Width/Height
: (100
,100
). - Set the
Canvas Scaler Dynamic Pixels Per Unit
to4
, to give the text some higher resolution.
The Canvas
gets a child Panel
, which in turn gets child Text
elements:
- Add a child of
GameCanvas
, create aUI
|Panel
, namedScorePanel
. - Set its
Rect Transform Left
:-40
, andRight
:40
. - If you've installed the
BallGame
assets pack, set itsSource Image
toCircle
(doughnut...