Playcanvas API changed?


I have a Playcanvas project with some instructions that used to work but don’t work now:

For instance:


What is the syntax for script creation now??;

What is the syntax for changing the skyBox textures now??

Thanks in advance.

Is it shareable? Would it be possible to post a link to it please?

Well, I prefer not to share the whole project.

Anyway, it seems that the API has changed and there are several things that I used to do that don’t work anymore, like creating a script or accessing the skybox.

They don’t work because the function does not exist anymore, so the project would not provide much information. I just need to know the new syntax.

AFAIK, the API hasn’t changed since 2016 for creating new scripts.

var OrbitCamera = pc.createScript('orbitCamera');

OrbitCamera.prototype.initialize = function () {
    var self = this;
    var onWindowResize = function () {


The method you have shown above is to add a new script instance of an existing script type that is in the registry to an entity and still exists in the engine code

This code worked last week:

var entity = new pc.Entity();

Now it does not work…

I mean, the code for ASSIGNING an existing script to an entity.
Not the code for designing a script…

It’s different.

Are you using the Editor or just the engine? The API hasn’t changed so if you don’t want to share your whole project just add me to take a look. My username is vaios.

I think you first need to attach the script component to the entity.


then you can use the script component “entity.script.create” :slight_smile:


I have solved it changing the code, but I am 99,99% sure, this code was working last week…

I have solved with your suggestion ( entity.addComponent(“script”); ) but I didn’t use this line before, and the code was working…

Very strange.
Are you sure the API hasn’t changed???;

was also working and does not work now either…

I think the dev team launched an important update of the engine (or are about to), so maybe there’s things that change! Always happen on evolving software, no biggie, we can help each other.

the setSource doesn’t appear to have changed tho:

The function is still there in the docs.

I think the problem is that defaults to null

I am almost sure it wasn’t that way before.

Again that all sounds weird. First of all you’re saying that before you were able to create a new entity and call entity.script.create on it without adding a script component? That would have never worked. They skybox would be null if you didn’t set one for you scene.

My impression is that something has changed in your project - otherwise if you can add me to a project that shows this behaviour then I could have a look.

I’ll double check if something has changed in my project.
Maybe you are right.

this one was my fault.

But I am sure there are other things that have changed, like


that I was using without addComponent()

I was also using

var texture = new pc.Texture();

and now it needs to have the graphicsDevice. Otherwise it doesn’t work.

var texture = new pc.Texture(graphicsDevice);

Several things have changed recently.
That’s for sure.

Thanks anyway!

When was the last time you were using PlayCanvas that these previously worked?

I don’t remember well.
It could be 2 weeks, 3 weeks, or a month. Something like that.

Very strange… I’m looking at the repo for Dec 2017 and pc.Texture API had always had graphicsDevice as a param:

It’s very odd that it worked before :thinking:

It did have the graphicsDevice as a param, but it worked without.

Okay, there is a way to figure it out for sure.

You have to run your project with old build.