Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Why is Unity not updating my scripts?

Discussion in 'Editor & General Support' started by zachwuzhere, Sep 25, 2017.

  1. zachwuzhere

    zachwuzhere

    Joined:
    Dec 21, 2016
    Posts:
    3
    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!
     
    nevhadini likes this.
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,194
    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.
     
  3. zachwuzhere

    zachwuzhere

    Joined:
    Dec 21, 2016
    Posts:
    3
    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.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
  5. zachwuzhere

    zachwuzhere

    Joined:
    Dec 21, 2016
    Posts:
    3
    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!
     
    Bec1991 likes this.
  6. Awesome123321

    Awesome123321

    Joined:
    Dec 26, 2015
    Posts:
    2
    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) +"%";) 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).
     
  7. mohamadabuasbe

    mohamadabuasbe

    Joined:
    Mar 4, 2021
    Posts:
    1
    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.
     
    HeMax210 and Vorper9 like this.
  8. BPJones

    BPJones

    Joined:
    Apr 12, 2021
    Posts:
    1
    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.
     
  9. gamedevelopmenttsunami

    gamedevelopmenttsunami

    Joined:
    Oct 1, 2016
    Posts:
    8
    Same problem. never had this before. Toggling Auto Refresh does nothing to fix this problem.
     
  10. fifiz12

    fifiz12

    Joined:
    Jun 1, 2021
    Posts:
    1
    for me reimporting worked.
     
  11. xSneepy

    xSneepy

    Joined:
    Jun 2, 2016
    Posts:
    2
    Still no solution? I checked everything (In Unity and in Visual studio aswell). Not sure sure what causing this problem :(
     
  12. richardaxeoz

    richardaxeoz

    Joined:
    Jun 9, 2019
    Posts:
    3
    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
     
    Last edited: Jun 30, 2021
    britbodenheimer likes this.
  13. Triton10

    Triton10

    Joined:
    May 23, 2021
    Posts:
    1
    I was having the same issue but this worked for me!
     
  14. annasmags

    annasmags

    Joined:
    Mar 16, 2021
    Posts:
    3
    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.
     
    Brother_77 likes this.
  15. pkiriakou

    pkiriakou

    Joined:
    Oct 2, 2012
    Posts:
    6
    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
     
  16. franpujolar

    franpujolar

    Joined:
    Dec 18, 2020
    Posts:
    9
    I had your exact error, creating a new script solved it.
     
  17. mtGameDev

    mtGameDev

    Joined:
    Oct 19, 2012
    Posts:
    89
    i have this problem. did you solve it ?
     
  18. howler123

    howler123

    Joined:
    May 7, 2017
    Posts:
    17
    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.
     
  19. HeMax210

    HeMax210

    Joined:
    Jul 26, 2021
    Posts:
    1
    Life saver. Having "Auto refresh" on helped me out. Don't know why it was disabled before (maybe I did something accidentally).
     
  20. PrOeZaXa

    PrOeZaXa

    Joined:
    Jan 5, 2022
    Posts:
    1
    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.
     
    Last edited: Apr 26, 2023
  21. EngineerTroy

    EngineerTroy

    Joined:
    Apr 27, 2020
    Posts:
    1
    I had a similar experience while rewriting an AudioManager script. The inspector showed the correct version but the serialized fields did not repopulate. Fixing the errors in the console by removing references to the original script did the trick.