Question by
Adesir35 · Feb 07, 2016 at 12:13 AM ·
warningargumentexception
The thing you want to instantiate is null & the variable nextTetrimino is assigned but its value is never used.
public static int gridWidth =10; public static int gridHeight =20;
// Use this for initialization
void Start () {
SpawnNextTetrimino();
}
// Update is called once per frame
void Update () {
}
public void SpawnNextTetrimino()
{
GameObject nextTetrimino = (GameObject) Instantiate (Resources.Load(GetRandomTetrimino(), typeof(GameObject)), new Vector2(5.0f, 20.0f), Quaternion.identity);
}
public bool CheckIsInsideGrid (Vector2 pos){
return ((int)pos.x >= 0 && (int)pos.x < gridWidth && (int)pos.y >= 0);
}
public Vector2 Round (Vector2 pos){
return new Vector2 (Mathf.Round (pos.x), Mathf.Round (pos.y));
}
string GetRandomTetrimino()
{
int randomTetrimino = Random.Range(1, 8);
string randomTetriminoName = "Prefabs/Tetromino_T";
switch (randomTetrimino)
{
case 1:
randomTetriminoName = "Prefabs/Tetromino_T";
break;
case 2:
randomTetriminoName = "Prefabs/Tetromino_Long";
break;
case 3:
randomTetriminoName = "Prefabs/Tetrimino_Square";
break;
case 4:
randomTetriminoName = "Prefabs/Tetrimino_J";
break;
case 5:
randomTetriminoName = "Prefabs/Tetrimino_S";
break;
case 6:
randomTetriminoName = "Prefabs/Tetrimino_Z";
break;
case 7:
randomTetriminoName = "Prefabs/Tetomino_L";
break;
}
return randomTetriminoName;
}
}
Comment
Your answer