using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class GameManager : MonoBehaviour { public GameObject prefab; public float Limit = 7; public float SpawnInterval = 2; float timer; public GameObject gameOverUI; public Text textscore; public void AddScore() { textscore.text = (int.Parse(textscore.text)+1).ToString(); } public void Restart() { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { } public void GameOver() { gameOverUI.SetActive(true); } // Update is called once per frame void Update() { if(timer < SpawnInterval ) { timer += Time.deltaTime; }else { timer =0; Instantiate (prefab,new Vector3 (Random.Range(-Limit,Limit), transform.position.y),Quaternion.identity); } } }