Question by
kupi · Jan 13, 2016 at 12:46 PM ·
prefabpublic variable
Can not set a public variable of a script or gameobject in prefab
I have a prefab that has a script which needs a reference to another gameobject (public variable). Normally i can just drag that other gameobject into the required field of the script component, but it doesn't work. When i use that prefab in my Hierarchy, i can assign the gameobject to the script but after hitting "Apply", it still doesn't change it in my prefab.
Comment
Best Answer
Answer by Hellium · Jan 13, 2016 at 12:33 PM
If you are editing a prefab in the Project view, you can't specify an object in your scene in the public field of your prefab. You need to give another prefab
Your answer
![](https://koobas.hobune.stream/wayback/20220612055930im_/https://answers.unity.com/themes/thub/images/avi.jpg)