Skip to content

Instantly share code, notes, and snippets.

@wmiller
Created January 28, 2014 03:06
Show Gist options
  • Save wmiller/8661658 to your computer and use it in GitHub Desktop.
Save wmiller/8661658 to your computer and use it in GitHub Desktop.
XML Database for Unity (Part 1) PlaceTile Method 1
public void PlaceTile(x, y, height)
{
string path;
if (height == 0)
{
path = "Tiles/WaterTile";
}
else if (height == 1)
{
path = "Tiles/GrassTile";
}
else if (height == 2)
{
path = "Tiles/DirtTile";
}
else if (height == 3)
{
path = "Tiles/StoneTile";
}
else
{
throw new System.Exception("Invalid height value");
}
Instantiate(Resources.Load(path) as GameObject,
new Vector3(x * tileWidth, 0.0f, y * tileHeight), Quaternion.identity);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment