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.
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 () .