- Home /
Unity game doesn't update when code changes
Whenever I make a change to the code and I press Play, the game runs as if I hadn't changed anything. The only way around this is restarting Unity, which takes almost 5 minutes, so that's not an option. The asset itself does get updated, as when I click on it the inspector shows the up-to-date file. Also, Unity does compile the file to the Library/ScriptAssemblies folder (I've checked with dnSpy and the changes do apply). It seems as if Unity uses an old version of the DLL only when running the game. I've tried restarting unity, reinstalling unity, recloning the game repo, restarting my pc, nothing works.
This is incredibly annoying and is making me unable to work on my game. Does anyone have any ideas?
Unity version: 2018.2.10f1. Also tried on 2018.2.2f1 and 2018.1.9f2.
Are you editing attribute values in code that have been changed in the editor? Unity will give preference to values input into the editor over your code changes. If so, setting a public variable to private, saving, then setting it back to public, will initialize the field and will default to the code value. If you are making actual structural changes (e.g. if statements) that are being ignored - this is not the solution.
Hello there,
Have you tried hitting Ctrl + R? Depending on the "Auto Refresh" setting under Edit->Preferences, you may have to manually tell Unity to Update and Recompile.
Answer by arbazgillani · Oct 02, 2018 at 06:07 AM
Delete the library folder and temp folder from project. Your issue would be solved. Unity have these few bugs. Please tell us which version you are using. So that I can dig a bit in it.
I've tried that to no avail. I edited the versions I tried with to the op.
In fact, I inspected the generated Assembly-CSharp.dll in the Library folder with dnSpy and it does get updated. It's like unity doesn't grab the latest version of that file when playing.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Dll distribution of Conditionally Compiled project 0 Answers
Having issues using my .dlls 1 Answer
how to connect to mssql in unity for hololesn (Build Setting Error) 0 Answers