GameObject GetTilePrefabForID(int tileID) { foreach (var tileObject in tilePrefabs) { CTile tileComponent = tileObject.GetComponent <CTile>(); if (tileComponent == null) { Debug.LogError("No Tile component attached to prefab " + tileObject.name); return(null); } if (tileComponent.GetId() == tileID) { return(tileObject); } } Debug.LogError("No tile prefab with ID " + tileID.ToString() + " found!"); return(null); }