The type or namespace could not be found?

While attempting to run my script, I get the same error 4 times on different lines, the error is as follows:

GameStartScript.cs(12,14): error CS0246: The type or namespace name `Tile' could not be found. Are you missing a using directive or an assembly reference?

Here is the start of my script up to line 12 where the first error occurs:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GameStartScript : MonoBehaviour {
	
	public int width; //Width of playing field
	public int height; //Height of playing field
	
	public GameObject tile;
	
	List<Tile> tiles = new List<Tile>();

I have defined width, height and the GameObject but something just isn’t working.

Does anyone have any ideas?

You haven’t defined Tile anywhere.

–Eric

I defined tile though which is a plane, surely I’m creating a list called Tile using multiple tile(s).

What would be the best solution then?

You haven’t…you have a variable called “tile” which is a GameObject, but you don’t have any Tile class. Maybe you want List.

–Eric

“Tile” isn’t the same as “tile” or “TILE”

Would be better to create a class Tile

public class Tile
{
  public GameObject goRef;
  public int otherTileVariables;
}

List<Tile> tiles = new List<Tile>();

What exactly do you mean? Could you elaborate please?

If it makes any difference, I have a script attached to the tile GameObject which the above script references later on but that isn’t what is calling the error though.

Thank you, I have actually just noticed what I have done wrong. I have a script attached to the tile which would be the aforementioned class but unfortunately I have named it TileScript instead of just Tile which has now fixed several errors.

Thank you, both for the help :slight_smile: