Live Reload
Live Reload requires Run in Background
to be turned ON in Player settings (under Resolution and Presentation).
The LiveReload
MonoBehaviour component watches your {ProjectDir}/OneJS
directory and will reload the ScriptEngine
(and your entry script) when code changes are detected. Settings:
- Run On Start (default On):
- Entry Script (default "index.js"): Which file to run on
ScriptEngine
reload. Note this should always be a .js file. - Watch Filter (default "*.js"): What type of files to watch
Multi-Device Live Reload
There is a 4th setting (Net Sync) that you can set to enable Live Reload across different devices. For example, you can make code changes in VSCode on your Desktop and have the change live reloaded on your deployed mobile app. Devices will self discover as long as they are on the same network (i.e. same wifi or lan).
After toggling on Net Sync, you can pick 3 modes:
- Auto defaults to Server for Desktop, and Client for Mobile
- Server will be responsible for broadcasting code changes to clients
- Client will be listening for code changes from Server
Janitor
A JanitorSpawner
should be used along side LiveReload
. It'll spawn a Janitor GameObject that will help cleaning up previous GameObjects and Console logs upon every Reload.