Hi guys,
I ve some problems about scene destroying and script destroying,Probably simple things but i cant figured it out.
I have 4 scene and changing between scenes thats ok.But when i change a scene , previous scene’s scripts dont stop and running.I destroy the old Hierarchy.But still running previous scene’s scripts.
The code that i’ve used is this
SceneManager.prototype.changeScenes = function(sceneName) {
const allScenes = pc.app.scenes.list(),
targetSceneData = allScenes.find(e=>e.name === sceneName);
if(!targetSceneData)throw new Error('Wrong Scene'); // Checking...
const sceneId = targetSceneData.url, oldHierarchy = this.app.root.findByName ('Root');
oldHierarchy.destroy();
this.loadScene (sceneId, (function (par) {
console.log(`${sceneName} Loaded successfully`);
currentScene = sceneName;
pc.app.lightmapper.bake();
}).bind(this));
};
SceneManager.prototype.loadScene = function (id, callback) {
pc.app.scenes.loadSceneHierarchy(id, function(err, parent){
if(!err){
callback(parent);
} else {
console.error (err);
}
});
};
This is not working for me.
And so i wanted to create a workaround for this.And i disable or destroy the entity which has scripts like this.
this.manager.script.destroy('sc');
this.entity.script.destroy('sc');
pc.app.root.findByName('manager').removeComponent('script')
But scripts never stops.Do you know something about this issue?