- Home /
UI Scene ending with Text
I need my game to end when the text shows this number. I am making a PONG game and I need help with this
using UnityEngine.SceneManagment;
public Text Player1ScoreText;
public int PlayerOneScore;
if (Player1ScoreText = 5)
{
SceneManager.LoadScene("Player1Win")
}
Answer by xxmariofer · Jan 18, 2019 at 10:58 PM
Well i imagine you are learning programming so you could just do this even it is inefficient is what you are looking
void Update()
{
if (Player1ScoreText == 5)
{
SceneManager.LoadScene("Player1Win")
}
}
Update is called every frame and for comparing porpuse you need ==, only one is for assigment
It says '==' cannot be applied to operands of type 'Text' and 'int'
Your answer
Follow this Question
Related Questions
Text.text doesnt work after scene change 2 Answers
Previous UI text sticks around even after reloading scene using SceneManager.LoadScene(scene.name); 0 Answers
Help with error message "Overwriting the same path as another open scene is not allowed" 0 Answers
Load Scene from .unity File 1 Answer
Main Menu Canvas and SetActive 1 Answer