- Home /
Scripts won't automatically update, always need to 'reset' them in the inspector for update
I'm running Unity v4.0.1 on Windows 7.
Is there any way to make my scripts automatically update when I save them in MonoDevelop?
They only seem to update in Unity when I either 'reset' them or move them to a different folder.
Thanks, Shoey
I got in to the habit of reloading my scene (remember to SAVE first)
Answer by Entevily · Aug 14, 2015 at 03:18 PM
I know this is a really old post. But I had this problem. To fix it, all I had to do was go into the Edit -> Preferences...
Once there, under the General Tab, I had to check the box for "Auto Refresh". That was it. When I save it now updates live in the game. I don't know why I ever unchecked that box. I hope this helps anyone who runs into this problem.
Oh my. I reïnstalled unity about 3 times, and this solved it.
I was working on an editortool and apparently EditorPrefs.DeleteAll() caused this bug for me.
Answer by Bunny83 · Jan 29, 2013 at 11:34 PM
The scripts will update unless you screwed up Unity in some way. However, how can you tell they don't update? If you mean setting new default values for public variables then yes, they won't change. The point of public variables is that you can change them in the inspector. If you initialize a variable in your script it will only use that value when the script-component is attached to an object or reset.
If you don't want to set them in the inspector, don't make them public like robertbu said. If you need them to be public to access them from another script but you don't want it to get serialized by unity, add the System.NonSerialized attribute to your variable.
"The scripts will update unless you screwed up Unity in some way."
Sorry but that is such a cop-out response. You automatically assume that Unity itself isn't the culprit, as if it's invulnerable to its own bugs. This problem has been happening with me, and others, as well. Code compiles fine, but (randomly) Unity doesn't acknowledge the newest version of a script, as if it's using a cached version.
Same problem has been raised here: http://answers.unity3d.com/questions/687519/scripts-compiling-but-not-updating.html
Answer by mx442 · Apr 02, 2013 at 06:15 PM
I was having the same problem, right-clicking in the project window and selecting "Sync Mono Develop Project" fixed it for me. I hope it helps.
Only workes once for me, I'll have to click "sync mono dev. project" every time I want to sync a script. It's really not that big of a deal, but it's very frustrating when you forget to click it and think there is something worng with the code.
Answer by robertbu · Jan 29, 2013 at 11:12 PM
Assuming you don't want them to show up in the inspector, you can make your variables private.
private int iVal; // C#
private var iVal : int; // Javascript
Variables in C# are private by default, but in Javascript they are public by default.
But shouldn't a change to the value in the code editor be reflected in the unity editor?
Answer by gamer2300 · Sep 11, 2013 at 11:17 PM
I have same problem i dont find right-clicking in the project window and selecting "Sync Mono Develop Project" but i click on reset on panel opf script and script is updated. I know is tedious but better of nothing...