[SOLVED] Saving Object States after the Editor Stops/Pauses

Is there a way to play and run code and then keep the changes after pausing?

If you’re asking where the code will run in the state that it is paused in.

…no. It doesn’t work that way.

No, I mean like: if I give a square controls, play the animation, move the square to the right. is there a way for the square to stay the same.

No. It will always reset to where you position it before the code will run. Since this isn’t a traditional code editor, instead frames can last longer than intended, then this would not work.

No, there is no a built in way to do that. You can do workarounds.

There’s a method for keeping a wick object in the same position inside the editor after pausing. I don’t talk about it much, but I did add it to pumpkinhead’s wick docs (I knew I was gonna forget about it and needed to write it somewhere)

“Clip._cachedSerializeData” returns the default data of “Clip”
It’s what the editor uses to know how to reset the project after it’s paused.

“Clip._cachedSerializeData.transformation” returns the default positions (and sizes) of Clip.
You can use this to set the default positions of the clip to that of its current positions while the project is running.

In other words, to keep a clip object in the same position that it was in while the project was running, add this one line to it’s update script:

this._cachedSerializeData.transformation=this.transformation;

With that line, the object will stay in the same position (with the same rotation, size, and etc.) once the project is paused without resetting. This will only happen to the clip that has that line of code.

Here’s an example: My Project5-1-2022_13-49-05.wick (1.7 KB)

1 Like

Thanks! @Hamzah_Al_Ani :D

1 Like