Skip to content

Commit 98abbeb

Browse files
committed
Get image url from texture's nativeUrl parameter
1 parent 1bc93e6 commit 98abbeb

File tree

1 file changed

+4
-4
lines changed
  • extensions/xsolla-commerce-sdk/assets/scripts/common

1 file changed

+4
-4
lines changed

extensions/xsolla-commerce-sdk/assets/scripts/common/ImageUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { assetManager, ImageAsset, SpriteFrame, Texture2D } from "cc";
55
export class ImageUtils {
66

77
static getBase64Image(texture: Texture2D, onComplete:(base64image: string) => void, onError?:(message: string) => void, outputFormat: string = 'png') {
8-
let data = texture.image.data;
9-
if(data instanceof HTMLImageElement){
8+
let url = texture.image.nativeUrl;
9+
if(url.length > 0){
1010
const img = new Image();
1111
img.crossOrigin = 'Anonymous';
1212
img.onload = () => {
@@ -21,9 +21,9 @@ export class ImageUtils {
2121
img.onerror = () => {
2222
onError?.('error occurs during texture loading');
2323
}
24-
img.src = data.src;
24+
img.src = url;
2525
} else {
26-
onError?.('texture must be HTMLImageDocument');
26+
onError?.(`texture's image.nativeUrl is empty`);
2727
}
2828
}
2929

0 commit comments

Comments
 (0)