
게임오버 기능까지 구현하고 점수 동기화로 넘어왔습니다.
점수동기화 코드까지 입력했는데 실행하니 점수동기화도 이루어지지 않고 패널 배경이 사라집니다.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class gameManager : MonoBehaviour
{
public GameObject square;
public Text timeTxt;
public GameObject endPanel;
public Text thisScoreTxt;
public static gameManager I;
float alive = 0f;
// Start is called before the first frame update
void Start()
{
InvokeRepeating("makeSquare", 0.0f, 0.5f);
}
// Update is called once per frame
void Update()
{
alive += Time.deltaTime;
timeTxt.text = alive.ToString("N2");
}
void makeSquare()
{
Instantiate(square);
}
void Awake()
{
I = this;
}
public void gameOver()
{
Time.timeScale = 0.0f;
endPanel.SetActive(true);
thisScoreTxt.text = alive.ToString("N2");
}
}
