private void Draw()
{
// get reference to the TileMap component
var map = (TileMap)this.target;
// Calculate the position of the mouse over the tile layer
var tilePos = this.GetTilePositionFromMouseLocation();
var prefab = map.Prefab;
// Given the tile position check to see if a tile has already been created at that location
prefab = GameObject.Find(string.Format("Tile_{0}_{1}", tilePos.x, tilePos.y));
// if there is already a tile present and it is not a child of the game object we can just exit.
if (prefab != null && prefab.transform.parent != map.transform)
{
return;
}
// if no game object was found we will create a cube
if (prefab == null)
{
prefab = GameObject.CreatePrimitive(PrimitiveType.Cube);
}
This will create Cube/s all the time.
I want to create the variable prefab.
In the map script at the top i did:
public GameObject Prefab;
So no the prefab is not a cube but something else.
How can i create now what is in prefab and not a cube ?