Live Script Reload (on device Hot-Reload)
Iterate on code insanely fast without breaking play session. Directly on device... 1. Play 2. Make change 3. See results
Are you tired of waiting for full domain-reload and script compilation every time you make a small code change?
Me too.
Tool will automatically compile only what you've changed and immediately hot-reload that into current play session.
Even better it'll do that on device, be it to already running .exe or deployed Android APK.
Iterate on whatever you're working on without restarting the app over and over again.
Works with any code editor.
Asset is a standalone extension to Fast Script Reload, you only need this package and single import to get started.
• Setup
1) Import
2) Create Build
2) Play Build and Editor
3) Make Code Change
4) See results
It's that simple.
• One-off custom code executions on Hot-Reload
When you need to set the stage to test your feature out.
Add following methods to changed script:
| void OnScriptHotReload()
| {
| //do whatever you want to do with access to instance via 'this'
| }
| static void OnScriptHotReloadNoInstance()
| {
| //do whatever you want to do without instance
| //useful if you've added brand new type
| // or want to simply execute some code without |any instance created.
| //Like reload scene, call test function etc
| }
• Performance
It's a development tool, you're not supposed to ship with it! :)
Your app performance won't be affected in any meaningful way though.
Biggest bit is additional memory used for your re-compiled code.
Won't be visuble unless you make 100s of changes in same play-session.
• Supports (Tested)
- Windows / Mac (Intel editor version only) / Linux
- Unity 2019.3
- Unity 2020.3
- Unity 2021.3
- Unity 2022.2
• Few things to have in mind, limitations:
• Generic methods and classes won't be Hot-Reloaded
Unfortunately generics will not be Hot-Reloaded, to workaround you'd need to move code to non-generic class / method.
• Creating new public methods
Hot-reload for new methods will only work with private methods (only called by changed code)
• Adding new fields (Experimental support added in 1.3)
You can now add new fields and tweak them in editor! Minor limitations:
- outside classes can not call new fields added at runtime
- new fields will only show in editor if they were already used (at least once)
- new fields will only work in editor workflow, they won't be propagated to build/device yet
• Extensive use of nested classed / structs
If your code-base contains lots of nested classes - you may see more compilation errors.
• Mac Silicon Editor version not supported
On Mac only Intel Editor version is supported. For Silicon version logs will show that everything is fine but actual change will not happen at runtime
• No IL2CPP support
Asset runs based on specific .NET functionality, IL2CPP builds will not be supported. Although as this is development workflow aid you can build your APK with Mono backend (android) and change later.
• Roadmap
- add Mac/Linux support - (DONE, added with 1.1)
- add debugger support for hot-reloaded scripts (DONE, added with 1.2)
- allow to add new fields (adjustable in Editor) (DONE, added with 1.3)
- better compiler support to work around limitations
• FAQ
- How is this asset different to Fast Script Reload?
> Live Script Reload is a standalone extension to FSR, it includes all features and allows for same hot-reload functionlity directly on deployed build. You only need this one to have both.
- When importing I'm getting error: 'Unable to update following assemblies: (...)/ImmersiveVRTools.Common.Runtime.dll'
> This happens occasionally, especially on upgrade between versions. It's harmless error that'll go away on play mode.
- When upgrading between versions, eg 1.1 to 1.2 example scene cubes are pink
> This is down to reimporting 'Point' prefab. Right now plugin will make sure it's using correct shader eg. URP / Built-in but only on initial import.
Technical details
- hot reload of code changes into current play session
- hot reload of code changes directly to running build over network