[SOLVED] LoadSceneSettings

Hello this instruction still works? is this correct? this.app.loadSceneSettings(‘898756.json’);

Hi @ayrin,

I think that method works if you provide the scene config file url, but it’s getting deprecated in favor of the new pc.SceneRegistry class introduced in the engine.

So the new way of doing that would be (using a scene name this time, not scene id!):

     var url = this.app.getSceneUrl("Scene Name");
     this.app.loadSceneSettings(url, function (err) {
        if (!err) {
            // success
        } else {
           // error
        }
     });
1 Like

But if i use loadSceneHierarchy i still need to use loadSceneSettings?

var url = this.app.getSceneUrl("Game");
                this.app.loadSceneHierarchy(url,function(err,entity) {
                    if (!err) {
                this.app.loadSceneSettings(url, function (err) {
                if (!err) {
                    // success
                } else {
                    // error
                }
                });
                } else {
                }
                });

Yes right, that would load the scene entities hierarchy only, settings have to be loaded separately.

yea but i have this error

My guess is that you are calling this function in a callback and this is in the wrong scope. Can you show where you are calling the load function please?

1 Like

Hi @ayrin,

Don’t forget to set the context! Either using a local var for app:

var app = this.app;

or using bind:

var url = this.app.getSceneUrl("Game");
                this.app.loadSceneHierarchy(url,function(err,entity) {
                    if (!err) {
                this.app.loadSceneSettings(url, function (err) {
                if (!err) {
                    // success
                } else {
                    // error
                }
                });
                } else {
                }
                }.bind(this));
1 Like

Yes @Leonidas it worked with bind(this) i always forget it…thanks @yaustar too

1 Like