i have some problems when switching between two scenes. I defined differend skyboxes, but if i load scene 2, the skybox of scene 1 is still set. When loading the scene directly within the playcanvas scene manager, the correct skybox is shown. Because i have to switch between those two scenes, i would have to find a solution the skybox which is placed within the scene settings (under renderer) is showed.
Right now i cant figure out, why the skybox isnt adjusted.
Found the problem. The settings were not updated, so the old settings from Scene 1 were used. If you came from unity3d scene management seems to be quite different in playcanvas
Currently I’m away from changing scenes again. I wanted to set up a new scene in the app to create a different skybox with a few adjustments, which should normally be quite easy and quick. However, I got various error messages when trying to switch back from scene 2 to scene 1. Now I wanted to change the skybox at runtime in scene 1, but this doesn’t work at all. I have defined the cubemaps as attributes, but they are not loaded or displayed correctly (just a white background). If I change the miplevel in the render settings at runtime, for example, it may still be displayed. What could be the reason for this? PlayCanvas seems to me to have a massive problem with changing skyboxes at runtime via script. Or is the script incomplete?
ChangeCubemap.attributes.add("skyboxs", { type: "asset", array: true });
// initialize code called once per entity
ChangeCubemap.prototype.initialize = function() {
var index = -1;
var preSkyBox;
// loop skyBox
if (++index >= this.skyboxs.length)
index = 1;
// // unload preSkyBox
if (preSkyBox)
preSkyBox.unload();
// set skyBox
preSkyBox = this.skyboxs[index];
this.setSkyBox(preSkyBox);
};
// load and set skybox
ChangeCubemap.prototype.setSkyBox = function(skyBox) {
if (!skyBox) {
console.warn("Skybox asset is null.");
this.app.setSkybox(null);
} else if (skyBox.resource) {
console.warn("Skybox is already loaded, no need to load again.");
this.app.setSkybox(skyBox.resource);
} else {
console.log("Loading skybox...");
skyBox.ready(function(asset) {
console.log("Skybox loaded.");
this.app.scene.skyboxMip = 1;
this.app.scene.skyboxIntensity = 1;
this.app.setSkybox(asset.resource);
}, this);
}
};
Note: i had several approches and found also online examples - but none of them worked properly