#Using the Editor Sync component seems to block automatic script changes to scripts?

1 messages · Page 1 of 1 (latest)

ornate verge
#

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

wide haven
#

Can you verify that you have hmr enabled?

ornate verge
#

Its on, this is a fresh project, I took the Editor sync out and rebuilt but the issue remains

#

Not sure why the hot reload isn't working now -

#

Changed this value from 0.1 to 1, it tells me the script is updated

wide haven
#

Because your methods are bound on start

#

on hot reload onDisable and onEnable is called

ornate verge
#

Ah I see

wide haven
#

so you would have to assign events there

ornate verge
#

Thanks, my bad in that case

#

I also put the console.log in update(), I assume it doesn't change there either

#

It doesn't work if I bind them in onEnable :/

#

Ah I see, it works if I set the values in onEnable, e.g. onEnable(){ this.rotationSpeed = 2;

wide haven
#

this.rotationSpeed is a field?

ornate verge
#

It's probably just by fluke I never noticed this as on other scripts I always happened to use onEnable to declare some values

#

It's just a number I set as a variable private rotationSpeed: number = 0.1;

#

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()

wide haven
#

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

ornate verge
#

I can work with this limitation now I know at least how it works