Why aren't my scripts updating in my project?
I installed Unity fresh a couple of days ago and started a new project. Scripts updated just fine for the first day and a half. I have been using Visual Studio as my IDE but have confirmed that this issue also occurs in MonoDevelop. Currently, anytime I make a change to a script, the script does not update inside of Unity. This also happens in another project that I created.
For example, if I change "public float projectileCollsionOffset = 4.0f;" to "public float projectileCollsionOffset = 5.0f;" in my script, I can look in the inspector and it will still be set to 4. Setting the number in the inspector also does not reflect the change in the script.
Removing the script completely from my player object and re-adding it after the changes are made does in fact work. However this is extremely tedious.
Can someone explain why this occurs and how to fix it?
I have read that it may have something to do with the meta files but haven't found any useful information on what to change with the meta files so that it fixes the issue. It may not even be related to meta files, but that's what I found so far.
Take a look at the console. I have found this to happen if one or more scripts have errors (an error will show up in red in the console).
Thanks for the reply. Unfortunately, there are no errors in the console.
I should also note that this evening I started a new project and ran into the same issue. I also uninstalled and reinstalled Unity and the issue still occurs.
I just upgraded it this morning and it still doesn't work.
Sometimes, for me at least, scripts won't update right away in the inspector, even when I save them. Try playing the script, that usually causes it to update for me.
Unfortunately, this did not work for me. When I highlight the script, I can see the change in the preview that shows up in the inspector. However, when I select my empty game object and look at the public variable, it did not change. So the value in the script is changing, but that change isn't making it's way to the inspector.
Adding to this, if I go to the script in the inspector and click the little gear in the top right corner, I can use the "Reset" option in the drop down to update the script. It's frustrating to say the least, but at least it's a temporary workaround. Still open to suggestions on how to fix the issue though.
Answer by GameEverything · Aug 31, 2017 at 03:48 AM
I'm really surprised there hasn't been an answer to this. Anyway, I had this problem today and I had no idea it was occurring until I asked myself if it was. I was going nuts thinking certain code wasn't accessible due to scope, etc.. Nope, it was that VS and Unity weren't actively syncing.
How it happened:
Had 5.6 project. Upgraded Unity to 2017. Upgraded VS to 2017. Updated 5.6 project to 2017.
Solution:
Reimported all assets.
The test:
Added simple Debug.Log statement to a Start function attached to a GameOjbect, pressed play in the editor, changed the parameter in the Debug statement, pressed play in the editor again, saw changes, changed the parameter in the Debug statement, pressed play in the editor again, saw changes, changed the Debug parameter and updated while playing in the editor, pressed stop, and finally pressed play again to see the changes.
Looks good to me so far. Of course, I'll come back here first thing if there are any problems.