Reaload the scene

I want to reload the scene rather than refreshing the window.Can you tell how to do that

var RestartButton = pc.createScript('restartButton');

RestartButton.prototype.initialize = function () {
    this.button = this.entity;
    this.button.element.on('mousedown', this.onButtonDown, this);
};

RestartButton.prototype.onButtonDown = function (event) {

    this.button.tween(this.button.getLocalScale())
        .to({ x: 0.7, y: 0.7, z: 0.7 }, 0.2, pc.SineOut)
        .on('complete', function () {
            this.button.tween(this.button.getLocalScale())
                .to({ x: 0.6, y: 0.6, z: 0.6 }, 0.2, pc.SineOut)
                .on('complete', function () {
                    window.location.reload();
                }.bind(this)).start()
        }.bind(this))
        .start();
};



Hi @gouthamamin,

Hmm, I think you could treat this similar to a regular scene change. Remove the current entity hierarchy and load and append the existing scene.

There is a guide here on how to approach scene loading: Loading Scenes | Learn PlayCanvas

2 Likes