Unity: How to fix Error CS0201? new objects expression cant be used as a statement

Viewed 69

How do I fix this problem when trying to run 2 different functions that do similar things? Both initialise a counter at 0 and then update based on an onmousedown script on a 3D object.

public class GameManager : MonoBehaviour
{
    public List<GameObject> targets;
    public TextMeshProUGUI mistakeText;
    public TextMeshProUGUI QAText;
    public int question;
    public int mistakes;
    void Start()

    {

        mistakes = 0;
        mistakeText.text = "Mistakes: " + mistakes;



        question = 0;
        QAText.text = "Question: " + question; " /10";
    }

    // Update is called once per frame
    public void UpdateMistakes(int mistakesToAdd)
    {
        mistakes += mistakesToAdd;
        mistakeText.text = "Mistakes: " + mistakes;
    }


    public void UpdateQuestion(int questionToAdd)
    {
        question += questionToAdd;
        QAText.text = "Question: " + question; "/10";
    }
}     

Image

1 Answers

Incorrect syntax for string concatination:

"Question: " + question; " /10";

->

"Question: " + question + " /10";
Related