C# program there is an error it says the private field Blockawn.block
is assigned but is never used.
The C# script is below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlockSpawn : MonoBehaviour
{
public GameObject[] Blocks;
public Transform BlockSpawnPos;
public int BlockCount = 0;
public float NewPos;
private int randomNum;
private float waitTime = 2.0f;
private GameObject block;
// Use this for initialization
void Start ()
{
Block();
}
// Update is called once per frame
void Update ()
{
}
public void Block()
{
block = Instantiate (Blocks [Random.Range (0, 5)], BlockSpawnPos.position, Quaternion.identity) as GameObject;
Vector3 temp = BlockSpawnPos.position;
temp.y = 0;
temp.x += 5;
temp.z = 0;
BlockSpawnPos.position = temp;
StartCoroutine (wait());
}
IEnumerator wait(){
yield return new WaitForSeconds (waitTime);
BlockCount += 1;
Block ();
}
}