Slightly Buggy Behavior in 2022.2.18

When I create a script in the project panel and then try to add it to the player game object it tells me the class doesn’t exist or the names don’t match, even if they do (yes, I double- and triple-checked everything and made sure all changes were saved).

If this happens to you, you can get around it by directly creating the script with Add Component on the game object (just type in the name you want the script to be and select “New Script”).

This is far from my first Unity project (where my Unity 4.X peeps at? :sweat_smile:) but the first time I’ve encountered this error, which makes me think it might have been a crossed wire somewhere in the compiler. I’m also using VS Community instead of VS Code, so it could also be an IDE miscommunication.

This happens in earlier versions, too. I get this in 2021.3 as well. But I find it only happens if I try to add it before Unity has had time to ‘import’ the new script, i.e. I’m too quick. If I give it a second, it’s all good

1 Like

Hm, I waited for it to compile before adding it to the GameObject, but :man_shrugging:t2:. Hasn’t been an issue on other scripts, just a weird little glitch. I could see it confusing or tripping up a first-timer if it happened to them, though.

Privacy & Terms