[SOLVED] How to get a texture width

I’ve passed a texture to my script using doing this…
ScriptName.attributes.add("completeImage", {type: "asset", assetType: "texture"});

later, at the initialize function I called this…
this.completeImage.width

This always return “undefined”.
Am I doing something wrong?

width is a property of the texture, not the asset which is what you are referencing.

In this case, you want to reference the data that the asset is pointing to, ie

this.completeImage.data.width

1 Like

Or when the resource is (pre)loaded you can ask for it’s dimensions using:

this.completeImage.resource.width

2 Likes