- Home /
Question by
theleonn · Aug 18, 2015 at 09:11 PM ·
errorparseunexpected-symbol
Why do I receive the message "Parse error: unexpected symbol ´int' " in the "public int y;" line ?
using UnityEngine;
using System.Collections;
public class GridItem : MonoBehaviour
{
public int x;
{
get;
private set;
}
public int y;
{
get;
private set;
}
public void OnItemPositionChanged (int nexX, int newY;)
{
x = newX;
y = newY;
gameObject.name = string.format ("Sprite [{0}][{1}]", x, y);
}
void OnMouseDown ()
{
print ("Click sobre esse item");
}
}
Comment
Answer by DoTA_KAMIKADzE · Aug 18, 2015 at 09:13 PM
Seems like you're completely new to c#, a lot of problems in your code, here is a corrected version for you:
using UnityEngine;
using System.Collections;
public class GridItem : MonoBehaviour
{
public int x
{
get;
private set;
}
public int y
{
get;
private set;
}
public void OnItemPositionChanged(int newX, int newY)
{
x = newX;
y = newY;
gameObject.name = string.Format("Sprite [{0}][{1}]", x, y);
}
void OnMouseDown()
{
print("Click sobre esse item");
}
}
You should really consider to start off with some tutorials and examples.
Answer by FortisVenaliter · Aug 18, 2015 at 09:13 PM
Because properties are defined by their blocks, whereas variables stand alone and are ended with a semicolon. Basically, the semicolon says "I'm done with this" and it's trying to figure out what to do with the blocks that follow. Remove the semicolon and it should work.
Your answer
Follow this Question
Related Questions
CG Shader Properties Parse Error 1 Answer
What I did wrong? Unexpected symbol `,', expecting `)' 1 Answer
Best JSON Parser + Errors 4 Answers
Not expecting void Start 2 Answers