Why is Unity not updating my scripts?

Whenever I save my script in Visual Studios, I go into Unity and it decides not to update to the new version I just compiled. So yeah my scripts are not updating in Unity (2017.1), the only fix I found was to restart my computer several times and eventually it will update.

Never had this problem with Unity 5.6(or any previous version), this started only after I updated to Unity 2017 a month or so ago. I tried looking through the Unity forums for a fix but nothing seems to fix it:(

What might be causing this problem? I thought I could just forget about it, but I can’t, Its KILLING ME!

1 Like

You might have automatic reloading turned off in the user preferences. It’s under Edit->Preferences, the checkbox is named “Auto Refresh”

As an alternative, if you right-click a script and select “reimport” (not reimport all!), it’ll recompile your scripts.

20 Likes

The “Auto refresh” is already checked. I unchecked it, closed unity and rechecked it, closed unity again and it didn’t fix it.
when I reimport the script it doesn’t update it either.

Do you have any compile or other errors in your console when you open the project?

Also there is this thread:

No there are no compile errors, but looking through that thread, looks like they have a possible fix in an upcoming patch (2017.1.1f2), I guess I’ll just hold off on Unity until then and work on my networking:) Thanks!

1 Like

Managed to figure out that my build was building correctly (the usual scripts used by others to show a loading bar showing synced values as integers as the bar loads does not work I had to use a different round method which was bizzar, the Mathf.RoundToInt(Value * 100) +“%”:wink: however there is an issue with the animator not displaying correct state changes. E.g. from and Idol to death state the death animation plays repeatedly (even with loop turned off on the animation). To by pass this as a poor workaround I have hashed out the animator bool on the script. I still have not found out why this should play fine in the game window but not in the build; does there need to be a script line to force back to the ‘avatar’ from the animation mode? (But I don’t think this is for this thread).

I don’t know if this is the same problem but here is the fix for it, its one minute fix

I hope this works for you.

4 Likes

I know I’m late to the party but I’ve had this same problem. For me saving the script updates it to Unity. I do have Auto Refresh on, but it doesn’t seem to be working.

1 Like

Same problem. never had this before. Toggling Auto Refresh does nothing to fix this problem.

for me reimporting worked.

Still no solution? I checked everything (In Unity and in Visual studio aswell). Not sure sure what causing this problem :frowning:

If that happens and you have Edit->Preferences->Auto-refresh on.
If the script is actually showing up in Unity updated but not working as expected to go to the GameObject where the script is attached and right click on the script component choosing the reset option.
It will work.
Here is a video showing step by step.

Cheers

1 Like

I was having the same issue but this worked for me!

Same problem. The scripts compile, and the changes even show up in the code preview in the inspector, but when I hit play, it runs like it hasn’t updated. Only way I can get it to respond to changes in my code is by closing the Unity editor and reopening it.

1 Like

I had the same problem. It turned out that when I copied my script (A.cs, class A) to create a new script(B.cs), I renamed the old class (A.cs, class B) leaving the old class name to the new script (B.cs, class A)

fixed when I fixed the class names to match the filenames

I had your exact error, creating a new script solved it.

i have this problem. did you solve it ?

I have the same problem, have even run debugger to see if everything was doing what it is supposed to do and it is. The editor is not updating the values in the editor in play mode. The debugger is showing they actually changed. I have auto refresh on and have restarted laptop and unity several times. I also have reimported everything and reset the scripts themselves to no avail. They are mono scripts showing a serialized class with a string and a set of Vector2’s that’s all.

Life saver. Having “Auto refresh” on helped me out. Don’t know why it was disabled before (maybe I did something accidentally).

1 Like

The only solution i Found was to make the variables constant but it won’t show up on the inspector, otherwise it will always compile and change. Do it only for the constant values in your projects
Edit : The other one is if you don’t want to make your variable constant, then you’ll have to click on the 3 dots of your component and then click reset, it resets the values to the newest ones in the script, the downside is it also resets the values of other parameters, such as linked scripts, rigidbody, etc.