I am doing a local storage system for some variable values in my project, but i realised that i need to differenciate the values that i am saving from one scene to other, as the scripts i am using in both scenes are the same but i need to store different values depending on the scene they are on.
For doing that i am trying to find a way of identifying in which scene that value is being stored, so i can add it to the storage item name. Something like the following:
if (storageAvailable('localStorage')) {
localStorage.setItem('var1' + this.currentScene.name , var1);
}
The problem is that I do not find any way of doing something like âthis.currentScene.nameâ (what obviously does not works)
Of course, this is assuming youâre using the manager to switch the scenes for you, but it works by keeping the manager in an initialization scene and then saving the name of the current scene and previous scene while additively working with any additional scenes.
There is no concept of âscenesâ in the way you are thinking about it in PlayCanvas
Each âsceneâ has a hierarchy and settings that are added/removed and applied. You donât actually âswitchâ scenes in PlayCanvas (read more here: Loading Scenes | Learn PlayCanvas)
What you can do is keep track of what scene hierarchy/settings you are loading and store it in a global variable.