Hot reloading (recompile and continue) with Entities?

I’ve been away from working with DOTS for a while and am coming back to it now. I had hoped to find that recompile and continue would be supported now, but that doesn’t seem to be the case out of the box.

I think that if I get a saving and loading system up and running, it should be possible to roll my own hot reloading via that. My project is pure ECS, apart from basic hybrid components like cameras. In theory, it should be as simple as saving when the scripts are about to reload, and restoring after. It’s not yet clear to me how well hybrid components and LiveLink are going to behave.

Things that I’m not sure of yet:

  • What’s the appropriate place in the Entities lifecycle to restore a world after assembly reload?
  • Am I going to have to do some extra magic on top of SerializeUtility to handle hybrid components and LiveLink?
  • Why isn’t this behaviour available by default or documented? I’m suspicious that I’m going to run into a reason that this won’t work.

Does anyone have something like this running, or any experience trying? I’d like to know about any references or best practices that work well in a larger project.

I found a few forum references from years ago where staff were saying that they expected this to be implemented at some point in the future, do we know if that’s still planned?

2 Likes

I’ve not done much more towards this yet, but looking at it it this may be impossible at the moment, at least to do cleanly.

The way that this fails by default is with a bug in GameObjectSceneManager.

Unloading the last loaded scene Assets/Scenes/SampleScene/New Sub Scene.unity(build index: 1), is not supported. Please use SceneManager.LoadScene()/EditorSceneManager.OpenScene() to switch to another scene.
UnityEngine.SceneManagement.SceneManager:UnloadSceneAsync (UnityEngine.SceneManagement.Scene)
Unity.Scenes.GameObjectSceneRefCount:ReleaseScene (Unity.Scenes.GameObjectSceneRefCount*)

That results in the main scene being destroyed and everything disappearing.

From what I can easily see, that’s not fixable without patching that file - which is doable of course because it’s in a package!

I’m finding it quite strange that this is so broken and erroring out. Weirdly, I can’t find anybody else talking about this issue… I can recreate it in a completely blank project so I think it must be universal, but I’m starting to wonder.

Can someone please confirm that this is the expected behaviour? Specifically, recompiling while in play mode is not meant to work when Entities and subscenes are involved, and the above error is experienced by everyone?

I’m in 2020.2.3 and Entities 0.17.0.