[SOLVED] Script Editor bug?

Hello,

I’ve found something that it seems to be a bug in the script editor.
It’s really strange bug, and it can be reproduced every single time.
I’ll try to explain it.

I’ve this piece of code:

entityA = new pc.Entity();
myTextureAssetA = pc.Asset();
myTextureAssetA = this.app.assets.find('dot.png');
entityA.addComponent("script");
entityA.script.create("sprite", {
    attributes: {
        textureAsset: myTextureAssetA,
        pos: [-5,119], size:[64,64]
    }}); 
    this.app.root.addChild(entityA);

I’m just instantiated a new sprite on the canvas.
Nice and smooth. It works as expected and display the dot.png on the right position.
Now… I wanted to pass the sprite coordinate in another way so I’ve instantiated a new pc.Vec2 like this:

var coordA = new pc.Vec2(-5,119);

and I’ve replaced the [-5,119] with coordA in the sprite instantiation like this:

entityA = new pc.Entity();
myTextureAssetA = pc.Asset();
myTextureAssetA = this.app.assets.find('dot.png');
entityA.addComponent("script");
entityA.script.create("sprite", {
    attributes: {
        textureAsset: myTextureAssetA,
        pos: coordA, size:[64,64]
    }}); 
    this.app.root.addChild(entityA);

As result the sprite is not displayed on the screen.
I’ve tried to understand why I couldn’t get the sprite shown, but without success. So I’ve decided to address the coordinate directly like in the first instance, so I’ve deleted coordA and I wrote back [-5,119] (please see the first block of code).

The sprite is not displayed anymore. Even if the code appear to be exactly the same like before.
I spent several hours to find out why now the sprite is not shown even if before, with the exact same code, was perfectly working as expected.

So, despaired, as last resource, I’ve commented the whole code block, and rewritten from scratch: I’ve rewritten the exact same code below the commented one.

Result: The sprite is not displayed as expected.

I’ve downloaded the working script and the non-working script on my local machine and opened with Visual Studio 2017 and they looks exactly the same.

What’s going on?

Can please anybody give me an explanation? I’m very worried that some other part of code can become un-executed (or whatever it is happening) and make the whole programming/debugging a nightmare.

Thank you.

Solved
I’ve downloaded the script. Deleted the original one from the editor. Created a new one with the same name and copy/pasted the content of the original script into the new one.
So far everything is working and I can’t reproduce the misbehavior anymore.

It’s possible that when you launched the game the browser was serving a cached version of your script. In the future try opening the browser console in the launch page and make sure you have disabled caching while the browser console is open. Also while the browser console is open you can see the code that is actually loaded for your script.