- Home /
Unity does not parse code properly.
I have a script 'fa' attached to an empty object. It contains the following:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class fa : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
public List<Vector2> housePositions = new List<Vector2>();
}
}
I am then presented with the following errors: Assets\fa.cs(14,1): error CS1022: Type or namespace definition, or end-of-file expected Assets\fa.cs(14,2): error CS1022: Type or namespace definition, or end-of-file expected Assets\fa.cs(9,6): error CS1513: } expected
Unless there is something obvious which I am completely missing, I am fairly sure that Unity just isn't parsing the code properly. I have tried uninstalling Unity and Unity Hub, deleting VS Tools 2015, deleting my project and reimporting it, installing other Unity versions. Pretty much everything I could think of, bar reinstalling windows. Is there something else that could potentially solve this?
Answer by xxmariofer · Dec 14, 2020 at 10:20 AM
If it only occurss with one script it is almost always your fault, in this case variables inside methods cant be public private or protected since they cant be access from other methods
void Start()
{
List<Vector2> housePositions = new List<Vector2>();
}
Unfortunately, whether it is public or private makes no difference in this instance.
I tell a lie, that seems to have completely fixed the issue. Thank you.