Game Development Reference
In-Depth Information
5. Set the second element of this array to
SelfDestruct
. With this, the
Info
button will create a new instance of a
popup_info
panel and destroy it-
self. The pattern we will use to return to the main menu will be such that the
popup_info
button allocates a new instance of the pop up when instructed
to do so, after which it will destroy itself. In this way, the content of the UI pop
up for both pages is completely contained inside the pop-up Prefabs we have
created in the editor.
6. Let's create a new script that manages the pop up at its top level; call
it
popupPanel
. Associate an instance of this script with the root of the
MainMenu
.
7. In this script, create a single public string named
nametxt
and a reference to
TextMesh
. In the
start
method, copy the public string variable's contents
over the top of the string member of the
TextMesh
. This gives a simpler in-
terface to name the pop up; we will use this script as a central place to inter-
face with the pop up.