handzlikchris / FastScriptReload

Hot Reload implementation for Unity. Iterate on code insanely fast without breaking play session. Supports any editor. 1. Play 2. Make change 3. See results
https://immersivevrtools.com/projects/fast-script-reload
MIT License
1.58k stars 113 forks source link
hot-reload unity unity3d

Documentation Video Quick Start Discord License: MIT

Are you tired of waiting for full domain-reload and script compilation every time you make a small code change?

Me too.

Fast Script Reload Watch Full Video

Fast Script Reload

Iterate on code insanely fast without breaking play session. Supports any editor. 1. Play 2. Make change 3. See results

Tool will automatically compile only what you've changed and immediately hot reload that into current play session.

Iterate on whatever you're working on without reentering play mode over and over again.

And you don't have to adjust your code either, just import.

Works with any code editor.

Quickstart

1) Download latest FSR version and import to Unity

You can also install via package manager. Window -> Package Manager -> + -> Add package from Git url: https://github.com/handzlikchris/FastScriptReload.git?path=Assets

Pulling other branches/commits can be done by appending branch name, eg https://github.com/handzlikchris/FastScriptReload.git?path=Assets#features/ai-code-rewrite-fixes 3) Play 3) Make Code Change 4) See results

It's that simple.

Quick start video created by Matt@SpeedTutor

Unity Asset Store Best Seller

I was really chuffed to see FSR selling over 1000 copies on Asset Store in February - propelling it to #1 best-selling for a few days and keeping on first page for most of the month.

Gaining reviews like:

Goosebumps and tears of joy

Felt like I was underwater and that I can breathe again. Just buy this stuff for any serious project. Working around the limitations is just worth it.

Hot-Reload on device / Live Script Reload

You can use same hot reload functionality in actual builds / on device. Iterate quickly on deployed Android APK / standalone windows build (exe).

It's a standalone, paid extension asset, if you'd like to support the product - please consider grabbing a copy on Unity Asset Store

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 visible unless you make 100s of changes in same play-session.

Supports (Tested)

Documentation

Full documentation is available here

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:

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

Other minor limitations

There are some other minor limitations, please consult full list

Roadmap

Soon whole roadmap will be published as Github project for better visibility.

FAQ

To fix please go to FastScripReload\Examples\Point\Point.prefab and search for 'Point' shader.

Building Hot Reload for Unity - blog posts about technical approach (with code)

I find FSR approach to hot reload very interesting (taking about being biased :)). I'm breaking down technical approach in a blog post series. You can find all about it here:

1) Building hot reload functionality | Download Example Project Code

2) Building hot reload for Unity builds / running directly on device | Download Example Project Code

Credits & Thanks

Support the project

If you got this far there's a good chance you're excited about FSR and want to help make it better. That'd be really cool! There are few things you can do that make huge difference.

Rave about FSR to other game devs!

Spread the word, let other devs know what it is, why is it cool and how it helps build your game. I'm sure once they try it they'll stay with us!

Help building it

Ping me on Discord if you've got some time on your hands and would like to contribute!

Doesn't have to be coding - there's a ton of stuff that can be done. Giving feedback on features, reporting issues, helping others get started or just chatting and helping build FSR community. All that helps a lot!

Become a patron

I'd love to continue spending most of my time making FSR better, as a indie dev however I need to balance that with paid client work. You can chip in to show your appreciation!

Support FSR by becoming a patron!