• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by tenfour04 · Aug 25, 2012 at 03:26 PM · editorvariableinspectornullclear

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tenfour04 · Aug 25, 2012 at 03:34 PM 0
Share

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.

avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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"

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Custom Inspector - How to add functionality? 1 Answer

Custom Construct Arrays in the Editor - can I control the name of the element? 0 Answers

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

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges