Error CS0201 while trying to modify the TD tutorial

Updated on November 16, 2018 in [A] Tutorials
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on November 13, 2018

In episodes 19 and 20 brackeys uses some neat snippets to tie his UI text elements for Upgrade and Sell to their prefab/blueprint values so that he only has to change them once and it changes everywhere.

 

So I thought I would try to do the same with the text elements of the initial cost in the shop by adapting what I had learned. I am currently in the process of trying to balance and it’s a pain to keep changing both.

 

Everything works fine when I hit play but Visual Studio shows the following error in the error box at the bottom:

 

Error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement (CS0201) (Assembly-CSharp)

 

First question is, if the game seems to be functioning properly is this a problem, and why?

 

And second, from my research, it seems this is usually produced by missing () or some other operant like + or = but I can’t for the life of me figure out what it should be.  Any ideas?

Code is as follows with the new/problematic code in lines 8-11 and 16-19:

using UnityEngine.UI;
using UnityEngine;
public class BuyTurret : MonoBehaviour {
public TurretBlueprint standardTurretPrefab;
public TurretBlueprint slowTurret;
public TurretBlueprint missleTurret;
public TurretBlueprint laserTurret;
public Text TurretCost;
public Text SlowCost; 
public Text MissleCost; 
public Text LaserCost;
BuildManager buildMaster;
void Start()
{
buildMaster = BuildManager.instance;
TurretCost.text = "$" + standardTurretPrefab.cost;
SlowCost.text = "$" + slowTurret.cost;
MissleCost.text = "$" + missleTurret.cost;
LaserCost.text = "$" + laserTurret.cost;
}
public void selectStandardTurret()
{
buildMaster.selectTurretToBuild(standardTurretPrefab);
}
public void selectSlowTurret()
{
buildMaster.selectTurretToBuild(slowTurret);
}
public void selectLaserTurret()
{
buildMaster.selectTurretToBuild(laserTurret);
}
public void selectMissleTurret()
{
buildMaster.selectTurretToBuild(missleTurret);
}
}

 

  • Liked by
Reply
1 on November 16, 2018

Can you tell me the line in which the error is?

From looking what you shared, I don’t see an error.

 

on November 16, 2018

Thanks for looking. The error message doesn’t say a specific line, it’s just as I copied and pasted it above. The only lines I can point to are 8-11 and 16-19 because the error appeared after they were added.

Show more replies
  • Liked by
Reply
Cancel