Make sure file name and class name match

I’m fairly new at Unity, (and by fairly new I mean VERY new) and I got this error when writing the script for a… um… thing named Health_box. When I got the error, I changed the line to “public class Health_box : MonoBehavior” and saved it. I went back into Unity (im using Microsoft Visual Studio btw) and tried to attach the script to Health_box. However, because I changed the name of the class to Health_box instead of whatever I had before, I got a lot of errors on the screen, and of course this meant that I couldn’t attach to script.

I need a way of changing the class without getting a bunch of errors, or at least a trick to allow me to attach the script even when there are errors. Anyone have any answers?

When you change the name of a class you need to change the file name to match. The best way to do that is from within Unity itself in the project tab.

check if there are compile errors or not ???It is mainly caused due to compile errors…@ankitkcapp11