JS script attached to game object not updating

I have a JS script attached to my gameobject, but when I make changes to that script, those changes aren’t reflected on the script attached to the object. When I inspect the script in Unity, the new changes appear, but it’s clear from my inserted debug statements that the gameobject is calling the older version of the script. Can anyone help?

Thanks!

If you’re talking about public variables, the values for those are taken from the inspector, not your script (aside from the initial assigment). It’s not using an older version.

–Eric

Nope, I’m talking about Debug statements like Debug.Log() and Debug.Break()

Maybe you’re editing the script while in Play mode.
Try Stop and re-Play, “Ctrl-P” “Ctrl-P”

It doesn’t matter if you’re editing a script in play mode; that’s not part of the editor so it makes no difference (and in fact you can make changes to scripts while the game is running and the changes will be applied in real time, with some limitations). Unity doesn’t keep versions of scripts; if you overwrite a script then the old version is gone.

–Eric

Right, but that doesn’t explain why my game breaks in my OnTriggerEnter() method even though my Debug.Break() line has been commented out.

Other problems are that a compile error in my script wouldn’t go away when I fixed the cause of the error (restarting Unity got rid of it, since I assume it compiled the updated script) and changing the text in my Debug.Log() log message made no difference and the old log code was still being output.

Something is wrong. I don’t know what, but I would really like to find out, if anyone can help.

I have the same problem, and it is quite annoying because you can’t use unity. :frowning:

I also have this problem. When I edit my script on Mono or any other editor Unity inspector shows the changes but when I hit play, Unity run the oldcode, without my changes. I have to build the project or reimport my scripts for Unity to “see” the changes.
I’ll try to reinstall Unity. Maybe that will work.

Anyone got any luck with this?

PS: I’m using C#
PS2: reinstallnig Unity did not fix it, but creating a new project did.