ScoreCanvas moves on scoring for SnowSufer

Hi,

I was following along on the SnowSurfer project (around Lessons 58 and 59), and my Scoreboard gets moved whenever I score points for some reason. Here is what happened in detail:

First, I noticed that the top half of the scoreboard was hidden because the fonts were too big. So, I moved ScoreText down a bit to make it fit within the screen.

It seemed fine at first, but when I scored points, it would shift back up so that the tp half is hidden again like this.

I am also attaching a screen of how it should look for comparison.

But, for the scoring logic, I do not change ScoreCanvas or ScoreText other than to set the Text. The code looks like this:

public class ScoreManager : MonoBehaviour

{

\[SerializeField\] TextMeshProUGUI scoreText;

int score = 0;

*public* void AddScore(int additionalScore)

{

    score += additionalScore;

    scoreText.text = "Score: " + score;

}

}

The only other places that deal with scores is the PlayerController where I have the following code:

[SerializeField] ScoreManager sManager;

void CalculateFlips()

{

    float currentRotation = transform.rotation.eulerAngles.z;

    totalRotation += Mathf.DeltaAngle(previousRotation, currentRotation);

    if (totalRotation > 340 || totalRotation < -340)

    {

        totalRotation = 0;

        sManager.AddScore(100);

    }

    previousRotation = currentRotation;

   

}

None of these move the ScoreText at all. So, could you please help me figure out what is going wrong here?

Best regards,

Sang-Woo

Hi Sang-Woo,

This problem might be caused by the TextMeshPro component.

  1. The text very likely wraps because the text box is too small. This is not necessarily wrong. It depends on what you want to see in your game. If the text is supposed to be in one line, increase the width of the text box.
  2. The “pivot” coordinates in your first screenshot are “wrong”. Since your anchor is at the top, I would recommend to set the pivot at the same position. Click the graphic in the top right corner (see your screenshot). There you can also set the pivot point. Alternatively, you could change the coordinates by typing values in the Transform component.

Here is the link to the manual: Basic Layout | uGUI | 2.5.0. I think the screenshots and gifs are quite helpful to understand how the UI works.

Have you already tested Flameshot or the Snipping Tool that is part of Windows?

Thank you. It fixed the bug.

Yes, I was using Snipping Tool.

Best regards,

Sang-Woo