How does Unity3D work with C# such that it doesn't have to reload the entire application every time you make changes?

Right now my “framework” code and my “gameplay” code are just one big thing. One big happy project. Perhaps this is a no-no, but for the scope of what I’m doing I don’t think it’s a big deal.

That being said it would be pretty cool to know how to separate these two ideas such that I could have my framework/engine be one thing that runs on it’s own and on top of that I’d have my gameplay/content layer. It would be pretty neat to know how to feed the framework/engine application C# code such that I don’t have to close and open the entire thing every time I make gameplay changes. Like how it works in Unity3D.

Thanks!

This is my project for some more context. It has a tilemap editor with things split across rooms. I can do some things without reloading the entire application, mostly just placing tiles described in the C# code. It would be neat to know how I might be able to “hot-reload” (am I misusing this term?) when I make changes to available tiles or maybe even things like the player code.

Here is an example for shaders maybe you can adapt it to other content also? Its a bit old so I don’t know if it works out of the box with the current version of MonoGame.

I don’t know for C# code.

1 Like

Microsoft.CodeAnalysis.CSharp.Scripting let’s one chunk of C# code compile and execute another. It’s very easy to use and only takes a few lines of code to implement. You can also save compiled code so you can load and run it without re-compiling. Methods and variables can be shared.

2 Likes

both helpful answers! that “Microsoft.CodeAnalysis.CSharp.Scripting” thing sounds like what i was looking for.

I also found this video about hotloading in monogame that other people might find interesting.