Destroy GameObject in my own Class
Hey guys, i have a GameObject in a custom Class and i want to destroy it. Is there a way to do that? When i call ChangeTile() it show's an error.
public class MapReader : Photon.MonoBehaviour
{
MapTile[,] mapTile;
public class MapTile
{
public int x, y;
public GameObject tileObject;
public TileType tileType;
public enum TileType
{
empty,
stone,
}
public MapTile(int x, int y, GameObject tileObject, TileType tileType)
{
x = this.x;
y = this.y;
tileObject = this.tileObject;
tileType = this.tileType;
}
}
void ChangeTile(int tileID, int x, int y)
{
Destroy(mapTile[x, y].tileObject)
mapTile[x, y] = new MapTile(
x,
y,
Instantiate(
tileObjectsToSpawn[tileID],
new Vector3(x, y, 0),
Quaternion.identity),
(MapTile.TileType)tileID);
}
}
What does the error says? I'm not familiar with Photon $$anonymous$$onoBehaviours but I would assume they'd have a Destroy method
Destroy(mapTile[x, y].tileObject)
is missing a semicolon at the end of the line (oops replied to comment, not answer... whatev)
So i guess
it show's an error.
actually ment a compiler error.... It seems to be extremely hard to write questions that could be understood. I don't know since i never ask one.
Anyways, downvote for bad question. I also move it to the help room as it's a trivial program$$anonymous$$g basics problem.
Your answer
Follow this Question
Related Questions
[SOLVED] Converting a Generic List to JSON in Unity 3 Answers
A good 2D tile map editor that works with Unity? 1 Answer
Destroy 2D obj issue 3 Answers
Movement and zoom of camera on the map 0 Answers