Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

I get 2 errors CS1547 and CS1525

Discussion in 'Scripting' started by Dreim, Feb 2, 2015.

  1. Dreim

    Dreim

    Joined:
    Feb 2, 2015
    Posts:
    4
    Hey guys..
    I'm kinda new with unity and I was watching some tutorials on youtube. I was folowing the tutorial and I'm stuck with 2 errors and I can't solve them.
    1. error CS1547: Keyword `void' cannot be used in this context
    2. error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[', or `='
    I checked the code multiple times still coudn't find the problem.. I did everything like the tutorial guy did and he didn't get the errors.. This is the code.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ItemManager : MonoBehaviour {
    5.    
    6.     public UnityEngine.UI.Text itemInfo;
    7.     public Click click;
    8.     public float cost;
    9.     public int tickValue;
    10.     public int count;
    11.     public string itemName;
    12.     private float baseCost;
    13.    
    14.     void Start(){
    15.         baseCost = cost;
    16.         )
    17.            
    18.         void Update(){
    19.             itemInfo.text = itemName + "\nCost: " + cost + "\nGold: " + tickValue + "/s";
    20.             )
    21.            
    22.             public void PurchasedItem(){
    23.                 if (click.Coin >= cost) {
    24.                     click.Coin -= cost;
    25.                     count += 1;
    26.                     cost = Mathf.Round (baseCost * Mathf.Pow(1.15f, count));
    27.                 }
    28.     )
    29. )                  
    30.  
    31.        
    I get error CS1547 at line 22.
    I get error CS1525 at line 16. and 20.
     
  2. Crayz

    Crayz

    Joined:
    Mar 17, 2014
    Posts:
    192
    Function and class declarations must begin and end with brackets { }. You're using a bracket to open your functions and class, but to close them you're using a parenthesis.

    Example:
    Code (csharp):
    1. void Start() {
    2.      baseCost = cost;
    3. }
     
    Dreim likes this.
  3. Dreim

    Dreim

    Joined:
    Feb 2, 2015
    Posts:
    4
    It worked thank you very much.