Live Script Reload (on device Hot-Reload)

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 2021.3

- Unity 2022.3

- Unity 6


• 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.


• Other minor limitations

There are some other minor limitations, please consult full list


• 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.


Release Notes

1.8

  • Added Unity 6 support
  • Improved extension methods rewriting
  • Partial classes support
  • Unity 2019 / 2020 no longer officially supported

1.7

  • File watching can be done via direct WindowsAPI
  • Extended UI to allow for easy choice of file watcher implementation

1.6

  • Added more Unit Tests to ensure various code patterns can be rewritten correctly
  • Added Watch Only Specific Files and Folders mode
  • Added better Odin support for dynamically added fields
  • Updated Roslyn lib version to 4.6.0 for better code parsing
  • Improved error handling for code parsing
  • Added Custom-File-Watcher implementation (for cases where standard FileWatcher API is causing issues)

1.5

  • you can now import FSR as a package from github page
  • hot-reloading internal interfaces / classes would no longer cause compilation error
  • OnScriptHotReload method can be added at runtime
  • builder functions will be correctly rewritten
  • hot reload status (red / green) will be visible in project panel next to changed script
  • compilation error reporting will be much improved, project panel will allow to click error next to actual file for more details and workarounds
  • all type declarations that were appended with __Patched_ postfix to avoid name collisions will also have all corresponding identifiers changed
  • OnScriptHotReload methods will also be called in editor-workflow

1.4

  • added experimental editor-mode hot-reload, you'll need to opt in via Start Screen -> Editor Hot-Reload (please read the notes on that page, playmode workflow is still far superior)
  • you can now define User Script Rewrite Overrides - which will allow you to overcome most of existing limitations that cause compilation errors (on a one by one basis)
  • big optimization in how long hot-reload part will take, first call will be unaffected when type cache is build but subsequent calls will be significantly quicker
  • added 'Exclude References' options - this allows to remove specific dll references from dynamically compiled code (as in some cases you may get 'type defined in both assembly x.dll and y.dll'
  • destructors will no longer cause compilation error
  • (options opt-in) script rewriting can optionally emit comment - why change was made to help with troubleshooting issues
  • Unity assembly reload can be forced off via LockAssemblyReload if specified in options - sometimes even though Auto-Refresh is turned off Editor still tries to recompile changes in playmode which prevents FSR from working
  • new fields support (experimental) will be enabled by default

1.3.1

  • open source release on github

1.3 - (Experimental) - New fields added in playmode

  • New fields can be added and used in code
  • New fields can be adjusted in editor (same as standard fields)
  • New fields will be initialized to whatever value is specified in code or default value
  • Experimental feature - at this stage expect some issues
  • Opt-in - disabled by default to enable go to 'Window -> Fast Script Reload -> Start Screen -> New Fields -> enable'

1.2 - Debugger support

  • Added debugger support (see documentation)

1.1 - Mac support / bug fixes

  • Added Mac support (only INTEL editor version, SILICON still not supported)
  • Added Linux support
  • fixed namespace clash with Unity.Collections package
  • common code lib will not be included in builds
  • added check for auto-refresh in Editor - will proide guidance and option to adjust as otherwise full editor reload is triggered for changes
  • added workaround for Unity file-watcher returning wrong file path on some editor versions
  • added option to allow disabling DidFieldCountCheck - allowing to detour methods in those cases (eg for Mirror where it'll adjust IL and cause mismatch)
  • added option to configure FileWatcher paths/filters as in some cases watching root directory was causing performance issues
  • added minor initial-load optimisations - using session-state for items that do not need to be resolved on every reload

1.0 - First release, included features:

  • Fast script reload in editor / play-mode (compiles only changed files and hot-reloads them into current play session)
  • Hot-reload on device (in build)

Basic Information
Latest Version
1.8 (25 Nov 2024)
Publisher
Chris Handzlik
Category
Tools/Utilities
Size
8.6 MB
Price
€32.19
Asset Rating
(10)
Extended Information
Unity Versions
2021.2.16, 2022.3.38, 6000.0.23
Render Pipelines
BIRP URP HDRP
State
published