[英]How can I remove these game objects when loading a new scene?
I am trying to create an augmented reality quiz game. 我正在尝试创建增强现实问答游戏。 However, I have a problem when I finish one quiz.
但是,当我完成一个测验时,我有一个问题。 The Data controller which contains the questions isn't being destroyed properly after ending the quiz.
结束测验后,包含问题的数据控制器未正确销毁。 It just adds up to the hierarchy.
它只是构成了层次结构。
By the way, I followed the Quiz Game tutorial from Unity. 顺便说一下,我遵循了Unity的Quiz Game教程。
public void EndRound () {
isRoundActive = false;
questionDisplay.SetActive (false);
roundEndDisplay.SetActive (true);
DestroyObject (FindObjectOfType<DataController> ());
}
How can I destroy the game object completely? 如何完全销毁游戏对象? So when I return to menu it will no longer add up and be part of the next quiz which will be selected.
因此,当我返回菜单时,它将不再累加并成为将要选择的下一个测验的一部分。 Thank you.
谢谢。
This: 这个:
DestroyObject (FindObjectOfType<DataController> ());
will only destroy the component DataController
. 只会破坏组件
DataController
。 To destroy the game object tree you can write: 要销毁游戏对象树,您可以编写:
DestroyObject (FindObjectOfType<DataController>().gameObject);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.