How to restart scene

Hi friends
Is there any simple way to restart the scene? ( I have single scene game )
If not, what’s your suggestion about it?
Thanks guys

Just calling this function with the name of the current scene should do the trick:

cc.director.loadScene('SceneName')

If you don’t know the name of the current scene you can do:

cc.director.loadScene(cc.director.getScene().name)
2 Likes

Thanks fleon, i did it first time but it doesn’t restart completely, it doesn’t trigger onLoad() and start() methods of my objects too, after using cc.director.loadScene(“name”), the result is different with original scene in IDE

In that case you should probably create a new empty scene and try this:

const currentScene = cc.director.getScene().name;
cc.director.loadScene('EmptyScene', () => cc.director.loadScene(currentScene));
1 Like

It was my bad, the problem was about using setInterval in start() method of controller. I have replaced setInterval with component.schedular and it’s ok now.
Thanks for you response :grinning:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.