- Home /
Help me to fix my script error cs1519
hello im following a tutorial but i have a problem at this point and i dont know where is the prob :(
Assets/Scripts/TileManager.cs(17,67): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
using UnityEngine; using System.Collections;
public class TileManager : MonoBehaviour {
public GameObject[] tilePrefabs;
public GameObject currentTile;
private static TileManager instance;
private Stack<GameObject> leftTiles - new Stack<GameObject>();
private Stack<GameObject> topTiles - new Stack<GameObject>();
public static TileManager Instance
{
get
{
if (instance == null)
{
instance = GameObject.FindObjectOfType<TileManager>();
}
return instance;
}
}
// Use this for initialization
void Start ()
{
CreateTiles (100);
for (int i = 0; i < 3000; i++)
{
SpawnTile();
}
}
// Update is called once per frame
void Update () {
}
public void CreateTiles(int amount)
{
for (int i= 0; i < amount; i++)
{
leftTiles.Push(Instantiate(tilePrefabs[0]));
topTiles.Push(Instantiate(tilePrefabs[1]));
topTiles.Peek().SetActive(false);
leftTiles.Peek().SetActive(false);
}
}
public void SpawnTile()
{
if (lefTiles.Count == 0 || topTiles.Count == 0)
{
CreateTiles(10);
}
int spawnPickUp = Random.Range (0, 8);
if (spawnPickUp == 0)
{
currentTile.transform.GetChild(1).gameObject.SetActive(true);
}
int randomIndex = Random.Range (0, 2);
if (randomIndex == 0)
{
GameObject tmp = leftTiles.Pop();
tmp.SetActive(true);
tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
currentTile = tmp;
}
else if(randomIndex == 1)
{
GameObject tmp = topTiles.Pop();
tmp.SetActive(true);
tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
currentTile = tmp;
}
//currentTile = (GameObject)Instantiate (tilePrefabs[randomIndex], currentTile.transform.GetChild(0).transform.GetChild (randomIndex).position, Quaternion.identity);
}
}
Answer by dubbreak · Jun 09, 2015 at 08:04 PM
It's a typo of some sort and you didn't copy/paste correctly so it's difficult to say.
Maybe the fact you have a dash instead of = ?
private Stack<GameObject> leftTiles - new Stack<GameObject>();
If you double click on the error it should take you to the correct line (though sometimes with syntax issues or typos it won't fall on the right line).
Your answer
![](https://koobas.hobune.stream/wayback/20220613200820im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
unity 3.4 crashes when i get to a certain point in the character generator script? 0 Answers
How to create a UnityScript array and access the data in each cell. 1 Answer
Serialize is working in debug, but it has no effect 0 Answers
How to delete animation event from .fbx file using script 0 Answers
Swapping animation clips at runtime 1 Answer