StartGameButton.cs 484 B

1234567891011121314151617181920212223242526
  1. using UnityEngine;
  2. public class StartGameButton : MonoBehaviour
  3. {
  4. public GameManager gameManager;
  5. // Start is called once before the first execution of Update after the MonoBehaviour is created
  6. void Start()
  7. {
  8. if (gameManager == null)
  9. {
  10. gameManager = FindFirstObjectByType<GameManager>();
  11. }
  12. }
  13. private void OnTriggerEnter(Collider other)
  14. {
  15. Destroy(other.gameObject);
  16. if (gameManager != null)
  17. {
  18. gameManager.StartGame();
  19. }
  20. }
  21. }