Assigning a gameobject (not a prefab) to a script in the inspector
It seems like there is a restriction in Unity that prevents me from assigning a scene game object to a public script variable inside the script's inspector. Unity only allows me to assign things that are in my Assets folder, but I cannot assign anything that is in the scene. I assume this is because scripts are supposed to be universal, but instanced game objects are per-scene. Is there any way, then, to create a game object (not a prefab) that exists in all scenes?
Otherwise, it appears that my only other option is to assign game object manually to each and every GO the script is attached to, which is certainly doable but tedious, or use a private variable instead and assign it using GameObject.Find(). Is that correct?
Answer by gorbit99 · Feb 11, 2016 at 05:26 PM
It's becuase if you get into an other scene, that doesn't have that gameObject, the script wouldn't know, what he should use
Your answer
Follow this Question
Related Questions
Addressables' references - right object is there, but not! 1 Answer
Problem Displaying PNG images with Transparency (or perhaps single colours) 0 Answers
Put a GameObject in the script's inspector when the script belongs to a prefab 1 Answer
I have prefabs that should be referencing different GameObjects, but they all refer to the same one. 0 Answers
Object looses Inspector properties When Scene returns 1 Answer