Unity score raising question

Asked 1 years ago, Updated 1 years ago, 126 views

You are about to write a code to keep score. There are several controls, so we split the code. In the event of a collision

scoreSum man = GameObject.Find("scoreManager").GetComponent <scoreSum>();
man.score ++;

I used to increase the score, and in the code scoreSum, I defined the text Sc and

void Start()

{

        score = 0;


}

void Update () 

{

        Sc.text = score.ToString();
}

This is how you continue to display your scores. However, the score is not initialized, and even if the score does not go up during the game, the score will not be displayed at once until the game is over and back to the game window. How should I fix it?

unity

2022-09-22 20:15

1 Answers

Is it correct that the text called Sc is well connected to the GameObject?

Isn't Text not connected well to Sc like the attached image?


2022-09-22 20:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.