I'm new to Unity and i am following a flappy bird tutorial to get a little more familiar with the game engine. i'm following the CodeMonkey tutorial. i'm at the game over screen. this is the script i have attached to my GameOverWindow. but only the Awake() gets called. the start doesn't. because of this my event is not working so the Game over window does not show.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using CodeMonkey.Utils;
public class GameOverWindow : MonoBehaviour
{
private Text scoreText;
// Start is called before the first frame update
private void Start()
{
Bird.GetInstance().OnDied += Bird_OnDied;
}
private void Awake()
{
scoreText = transform.Find("scoreText").GetComponent<Text>();
transform.Find("retryBtn").GetComponent<Button_UI>().ClickFunc = () => { UnityEngine.SceneManagement.SceneManager.LoadScene("GameScene"); };
Hide();
}
private void Bird_OnDied(object sender, System.EventArgs e)
{
scoreText.text = Level.GetInstance().GetPipesPassedCount().ToString();
Show();
}
// Update is called once per frame
private void Update()
{
}
private void Hide()
{
gameObject.SetActive(false);
}
private void Show()
{
gameObject.SetActive(true);
}
}