BabylonJS / Editor

Community managed visual editor for Babylon.js
http://editor.babylonjs.com/
813 stars 232 forks source link

Missing Preview Stop lifecycle event #365

Closed ggcaponetto closed 2 years ago

ggcaponetto commented 2 years ago

Hello

I am new to BJS and am struggling understanding the lifecycles of a script attached to a Node.

Let's say I connect to websockts on the public onStart(). Where in the code am I supposed to close the connection when I press the stop button in the preview of the editor?

Is there a lifecycle method like onStop()/onDispose()/onEditorStop() or something like that?

The socket disconnects only if I run the project in the browser and I close it, but not in the preview of the editor.

julien-moreau commented 2 years ago

Hi @ggcaponetto ! Just added "onStop" function that can be implemented in scripts. I just released v4.1.1 of the Editor that includes this enhancement

The onStop function is called on the component is disposed. Also, when editor stops, all components are disposed so the onStop function is called.

Thanks for that request :)

ggcaponetto commented 2 years ago

@julien-moreau It works. Thanks for adding this quickly.