I just realized that we can do hotswapping in Unity 4 now. Before this release, if I would alter the code in any way while the game was running in the editor, I would get a Null Reference exception, it's no longer the case. Can anyone validate this? If it's correct, why isn't it in the release notes?
I don't recall this being an issue in Unity 3 either, with the exception of static variables (recompiling seemed to reset any static references). Does it no longer reset static references or am I missing something?
Recompiling in play mode has always broken things for me for a long while now. My current projects are still in Unity 3, though, haven't tried 4.
Would be interesting to know how hot swapping is meant to work - I usually consider it a bug because it breaks my running game without explanation. If I knew how it worked... then maybe it could be an asset. Just hot swapped some mouse look code and it worked in Unity4.
From what I understand, it's mostly the same as before. When code is recompiled, everything is serialized, Mono is re-initialized, and then serialized values are pulled back in. Only things that are serialized into C++ land and then back are saved (public inspector variables, [SerializeField] stuff that Unity supports, ScriptableObjects, etc. So static variables will be re-initialized, private non-serialized variables reinitialized, etc. There was a blog post about Unity's serialization made not too long ago - if you design your code right, you can actually have hot swapping working (It's pretty tricky though and sometimes not really possible)
hotswapping is possible in unity. we use call c sharp code in lua and hotswap lua script from web server. search bblua + bbupdate in assetstore.
I blame Google for all these necro instances. It seems that recently search results include at the top articles and posts from long ago, where as before it would show more recent results first. Then again, people could check to see when a thread was posted or last responded to before replying...