完成Zig Zag游戏后,我正在使用Unity 2018.2.18f1。当我单击启动时,会出现一条错误消息,显示NullReferenceException:对象未设置为对象的实例。它总是在GameManager脚本中发生。你能帮我吗?
GameManager Javascript的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour {
public static GameManager instance { get; private set; }
public bool gameOver;
void Awake()
{
if(instance == null)
{
instance = this;
}
}
// Use this for initialization
void Start () {
gameOver = false;
}
// Update is called once per frame
void Update () {
}
public void StartGame()
{
UIManager.instance.GameStart();
ScoreManager.instance.startScore();
GameObject.Find("PlatformSpawner").GetComponent <PlatformSpawner>().StartSpawningPlatforms();
}
public void GameOver()
{
UIManager.instance.GameOver();
ScoreManager.instance.stopScore();
gameOver = true;
}
}