Sliders and checkboxes still appearing after changing scene

While making a setting’s menu I made it so that you could change the options using checkboxes and sliders, but when I change the scene they still appear. The script that may be affecting this are: Slider, Checkbox, and all the settings scripts.

My project: PlayCanvas 3D HTML5 Game Engine

Hello, @Literally_Kirby

I checked out your project and found that reason.

The reason is that when creating Slider and Checkbox in PlayCanvas, a new node is added to the DOM rather than within the PlayCanvas internal structure.

changeScene Method doesn’t touch DOM Tree.
Therefore, you should remove slider and checkbox by yourself before scene change.

1 Like

What would be the best way to do this in the change scene script?

When ever I leave the settings menu, the actual settings will save but the slider and check boxes will appear as if they refreshed. PlayCanvas 3D HTML5 Game Engine

Hmm, I think that you can remove input element using document.getElementsByTagName() before calling changeScene Method.


Use this one.

When creating the element, you can place the existing value in the ‘value’ part if it already exists.

I 'm sorry but I am using this, and wouldn’t your below solution mean that I would have to make a new script for every input?

and also, while using a different size monitor the input’s position skewed.

The reason I recommended the solution below is also due to resolution issues.

The method of directly adding to the HTML DOM requires a process of calculating the position based on the PlayCanvas UI (outputting at the desired location). Still, it may slightly deviate depending on the device.

However, if you structure it with PlayCanvas UI, it could simplify the cumbersome process.

So, choose the method that suits your preference.