How do you retain a name of a node when being instantiated at runtime? I am making a quiz game where the player will choose how many number of quizzes to be instantiated.
There is a Quiz Container node that I made that is empty. It will only be filled when the player provided the number of quizzes at runtime. To make this short, I need a reference to those instantiated nodes.
I did a quiz_number variable and it works. Example, I instantiate 5 Quiz Buttons. Quiz1 Button’s text has the quiz_number 1, Quiz2 Button’s text has the quiz_number 2 as I see it on the Remote tab in the scene tree. I also see the Quiz Button names in the scene tree as normal (QuizButton@…, something like this).
But the problem is, when I instantiate an additional 5 quiz buttons, the quiz_number variable inside a QuizButton is still correct but the QuizButton names are different. Why is that happening? Or is there any way to do this differently (Like using groups or something)?
Screenshot 1: The Quiz 1 button reference is encircled on blue ink. The selected quiz is pointed by the arrow.
Screenshot 2: The name of the QuizButton (encircled by blue ink) is now different as I add 4 more QuizButtons. However, the current selected quiz is the same.
I think my reply stands. Though why do you need the name of the instantiated button to be legible? Your screenshots seem like the name should not matter, could you explain the big picture issue you’re having? Why do you think you need to retain the names of the instantiated scene?
What I need to do is when I am on the main scene, I want to hide every children of a QuizContainer node and show only the current Quiz node selected while the player starts answering the quizzes. But is there another way to do this?
What I did back then is when I am on the Create Quiz scene, the questions and answers that is written right there will go to a different scene called Quiz Answering Scene. Now I got a problem that when I write a quiz, that written questions and answers do not go to the Quiz Answering scene because I am using preload and load instead of just hiding and showing them.