I
I
ILIIA22892019-10-30 18:23:01
Unity
ILIIA2289, 2019-10-30 18:23:01

How to fix this? unity 2019.2.10f1?

In short, such an error: the
English version of the error:

error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

Russian version:
Ошибка CS0201: в качестве оператора могут использоваться только выражения присваивания, вызова, приращения, уменьшения, ожидания и новых объектов

My code
using UnityEngine;
using UnityEngine.UI;

public class game : MonoBehaviour
{
    public Text scoreText;
    public GameObject shopPan;
    private int score;
    private int bonus = 1;
    public int[] shopCosts;
    public int[] shopBonuses;
    public Text[] shopBttnsText;
   

    public void shopPan_ShowAndHide()
    {
        shopPan.SetActive(!shopPan.activeSelf);
    }

    public void shopBttn_addBonus(int index)
    {
        if (score >= shopCosts[index])
        {
            bonus += shopBonuses[index];
            score -= shopCosts[index];
            shopCosts[index] *= 2;
            shopBttnsText[index].text = "BUY UPGRADE \n"; + shopCosts[index] + "$" ;
        }
        else
        {
            Debug.Log("Not enought money");
        }
    }

    public void onClick()
    {
        score += bonus;
        scoreText.text = score + "$";
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-10-30
@ILIIA2289

Apparently there's a semicolon in the middle of the line:

shopBttnsText[index].text = "BUY UPGRADE \n"; + shopCosts[index] + "$" ;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question