Я использую Unity 2019.3.0a4. Объект игры отображается в редакторе сцены, но не отображается на экране игры. Хотя он полностью функционален, я могу передвигаться и все равно делать все, что мог обычно делать.
//This is in the script in the player, the gameobject that is invisible:
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "Enemy")
{
GameObject gameCtrl = GameObject.Find("GameControl");
GameController gameController = gameCtrl.GetComponent<GameController>();
gameController.life--;
gameController.isDead = true;
player.SetActive(false);
}
}
//This is in another script in another object, so that it would work even when the player in inactive:
private void Update()
{
if (isDead == true)
{
respawnUI.SetActive(true);
}
if (isDead == true && Input.GetKeyDown(KeyCode.R))
{
respawnUI.SetActive(false);
isDead = false;
player.transform.position = spawnPoint.transform.position;
player.SetActive(true);
}
}
}
//Both scripts are correctly referencing the player gameobject.
Нет сообщений об ошибках. Все остальное работает, игровой объект игрока просто невидим на игровом экране.