Home unity3d Why are objects on stage in the prefaba window?

Why are objects on stage in the prefaba window?




Recently, I am trying to figure out how prefabs are arranged in Unity. I have a prefab “Sea”. It hangs the “Button_script” script, which has a public gameObject Player_choice. When opening the prefab, the scene is closed in the hierarchy window. When you click on the circle next to Player_choice, a window opens, but only prefabs are visible. Please do not need to offer to use GameObject.find … I just want to know why it is impossible to manually put the value of the object?! Or is it possible?



Answer 1, Authority 100%

At the time of creating a copy of the prefab of these objects on the scene may not be. Therefore, we cannot point out links to them in prefabach. And no one guarantees that the prefabs will sleep on the same scene. If you try to keep the object in the prefab, which have such links, they will turn everything into NONE (there will be NULL in the code).

Only objects on the same scene can refer to the scene objects. So you can pull out the prefab on the scene and select the desired object from it.

Answer 2

Maybe I did not understand the question correctly, but if you want to “spawn” objects during the game and assign action to the buttons, then you need AddListener () .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions