- Home /
How do you clear a variable in the inspector?
I have a MonoBehaviour that I use in many places throughout my project. There is one public AudioClip variable that gets used if it's assigned, but I intentionally leave it null on GameObjects where I don't want to play a sound.
Now I've accidentally dragged an audio clip onto this variable on one of the GameObjects that should not play a sound. How do I clear it back to null without having to delete the script and adding it again?
Answer by tenfour04 · Aug 25, 2012 at 04:26 PM
I stumbled on the answer by experimenting. You just click the variable and hit the Delete key!
Answer by fafase · Aug 25, 2012 at 03:27 PM
in the start function of the script attached
audio.clip=null;
Ok, so what you want is click the little circle on the right of the slot. That opens a new window with all your sounds. The first one is none.
Since I use this $$anonymous$$onoBehaviour many times, and I often do not want the variable to be null, this wouldn't work in this case.
Answer by Eric5h5 · Aug 25, 2012 at 03:41 PM
Click on the selector for the appropriate slot in the inspector and select "none" from the list.
Answer by alemas · Apr 20, 2017 at 07:26 AM
Click the setting button in the top right corner and int the drop down menu click: "Reset" or "Revert to prefab"
Your answer
Follow this Question
Related Questions
calculate things... and display in inspector 3 Answers
Defining a public variable with 'where' 2 Answers
Is there a Function Callback for when a vairable is altered in the Inspector? 1 Answer
Public Scene Variables not appearing in the inspector 2 Answers
Hide public field on base class but show it on derived class 1 Answer