Bug? Error when trying to load a new texture from code

Right, so if you want a custom name, then you have to create the pc.Asset instance yourself then. Much like you’ve already found out, here is the correct way to do that:

var asset = new pc.Asset("My Asset Name", "texture", {
  url: "https://c1.staticflickr.com/9/8873/18598400202_3af67ef38f_q.jpg",
});

this.app.assets.add(asset);

asset.ready(
  function () {
    console.log(this.app.assets.find("My Asset Name"));
  }.bind(this)
);

this.app.assets.load(asset);
1 Like