Can I tell the editor to ignore this compile warning? [Answered]

I have a lot of variables set up to be used later, and the list is growing. And every time I compile my code the editor returns these warning saying “variable such-and-such is assigned but the variable is never used!”

Is there a way I can tell the editor to not display those warnings? It’s gotten to the point where I could miss a new and relevant warning.

Just put // before the variable until its needed I guess?

Sorry for the lackluster answer, I dont really know what you can do :confused:

Did you try those toggles?

1 Like

Yeah but that would clear ALL the warnings. It’s not too common, but every now and then I write something that generates a warning and not an error, and I don’t want to miss it.

I just want to miss these ones that tell me a variable is never used.
At least for the foreseeable future.

Add this to the top of your script.

#pragma warning disable 0649

Generally speaking, if you do have a warning you want to ignore, simple look at it. It’ll give you a unique warning code aswell. For not assigned variable’s it is CS0649. Just put the four numbers into the above pragma and the compiler will ignore them.

1 Like

It’s good practice to do a restore afterwards, though. Warnings are there for a reason, so while you want to suppress them where you’re making a deliberate choice, you do want them to appear when you’re not doing that.

It works! My code was CS0414 so I had to change the number at the end, but it works just like I wanted!

Oh yeah. I wouldn’t be hiding this one if it wasn’t for the exact nature of the warning in this circumstance. And even then I’m only hiding it so I don’t wind up missing other warnings.

Indeed, that’s the ideal reason to do this kind of thing. I was mostly posting to point out that there was a “restore” option too and that people should generally use it hand in hand with their “disable” calls.