
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
GameManager 코드입니다. 시간 제한 로직을 update()에 넣어도 유니티로 실행했을 때 반영이 되지 않습니다.. 이유와 해결 방법이 궁금합니다
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public static GameManager Instance;
public Card firstCard;
public Card secondCard;
public int cardCount = 0;
public Text timeTxt;
public GameObject endTxt;
float time = 0.0f;
private void Awake()
{
if(Instance == null)
{
Instance = this;
}
}
// Start is called before the first frame update
void Start()
{
Time.timeScale = 1.0f;
}
// Update is called once per frame
void Update()
{
time += Time.deltaTime;
timeTxt.text = time.ToString("N2");
}
public void Matched()
{
if(firstCard.idx== secondCard.idx)
{
//파괴
firstCard.DestroyCard();
secondCard.DestroyCard();
cardCount -= 2;
if (cardCount == 0)
{
EndGame();
}
if (time >= 30.0f)
{
EndGame();
}
}
else
{
//닫기
firstCard.CloseCard();
secondCard.CloseCard();
}
firstCard = null;
secondCard = null;
}
private void EndGame()
{
Time.timeScale = 0.0f;
endTxt.SetActive(true);
}
}
