Usually when editing scripts prior to adding the Editor Sync component, I could change a .ts script in VS code and those code changes would populate to the browser side of the script and I would see the notification in browser of: ‘script changes applied (HMR)’. Since using the Editor Sync Component in the scene, when I do this now the code changes don’t populate until I refresh the browser window.
See gif example attached
Original Post on Discord
by user 103054507105067008
marcel
(marwi)
March 29, 2023, 12:00am
2
Can you verify that you have hmr enabled?
Its on, this is a fresh project, I took the Editor sync out and rebuilt but the issue remains
by user 103054507105067008
Not sure why the hot reload isn’t working now -
by user 103054507105067008
Changed this value from 0.1 to 1, it tells me the script is updated
by user 103054507105067008
marcel
(marwi)
March 29, 2023, 12:00am
6
Because your methods are bound on start
marcel
(marwi)
March 29, 2023, 12:00am
7
on hot reload onDisable and onEnable is called
Ah I see
by user 103054507105067008
marcel
(marwi)
March 29, 2023, 12:00am
9
so you would have to assign events there
Thanks, my bad in that case
by user 103054507105067008
I also put the console.log in update(), I assume it doesn’t change there either
by user 103054507105067008
It doesn’t work if I bind them in onEnable
by user 103054507105067008
Ah I see, it works if I set the values in onEnable, e.g. onEnable(){ this.rotationSpeed = 2;
by user 103054507105067008
marcel
(marwi)
March 29, 2023, 12:00am
14
this.rotationSpeed
is a field?
It’s probably just by fluke I never noticed this as on other scripts I always happened to use onEnable to declare some values
by user 103054507105067008
It’s just a number I set as a variable private rotationSpeed: number = 0.1;
by user 103054507105067008
But if I change the value of it where it is declared at the top of the script, hot reload doesn’t reflect that unless I set it manually in onEnable()
by user 103054507105067008
marcel
(marwi)
March 29, 2023, 12:00am
18
Ok. I think the design idea was: it’s not clear if a changed variable was made by your edits or mutation so we dont re-assign the original value
I can work with this limitation now I know at least how it works
by user 103054507105067008