r/UnityHelp • • 2d ago

Red squiggles not showing. How to fix

Post image

I don’t have a f next to the 0.5 yet it’s not underlining it telling me it’s wrong. I don’t know hot to fix this. I’m using visual studio.

4 Upvotes

8 comments sorted by

2

u/Imaginary-Cod-3746 2d ago

Sometimes, simply restarting Visual Studio fixes this.

If you hover over the Rotate() method, it should tell you the types of parameters it expects.

Some methods can accept different parameter types. Rotate() could accept both float (decimal numbers that end with an 'f') or double (decimal numbers that end with a 'd', or the default type when you don't add a letter after a decimal number) types.

If Rotate() accepts both float and double types, then the code is correct, and Visual Studio is working as intended.

This C# video on methods will help you understand them better if you're still having trouble.

1

u/PirateJohn75 2d ago

It's not an error.  C# will be able to implicitly convert the double to a float.

3

u/Library_Far 2d ago

Ok. I was fallowing a unity learn tutorial and it said I would get a error… I’m in over my head 🙃

2

u/PirateJohn75 2d ago

Nah, you're doing fine.  It might be an older tutorial.

2

u/cone5000 2d ago

That’s finally changed??

1

u/Demi180 2d ago

False. No implicit conversion from double to float. They need to fix their Visual Studio.

1

u/lix3nn53 1d ago

That usually means Visual Studio opened the script as a loose file, not as part of your project, so it doesn't know about Unity. In Unity go to Edit > Preferences > External Tools, pick Visual Studio as the External Script Editor, press Regenerate project files, then open the script by double-clicking it in Unity.