본문 바로가기
Cocos Creator

SpriteFrame png파일 로드 Bundle resources doesn't contain 해결

by 개발자언니 2025. 10. 17.

아래 경로와 같이 assets 폴더 내에 resources 폴더 아래 box_main.png 파일을 불러오기 위해

assets/resources/box_main.png

const sf = await new Promise<SpriteFrame>((res, rej) => {
resources.load('box_main', SpriteFrame, (e, f)=> e ? rej(e) : res(f));
});

 

정말 몇 줄 알되는 코드를 작성했는데 아래와 같은 에러가 난다. 

Error: Bundle resources doesn't contain box_main 2025-10-16 15:30:20 [PreviewInEditor] Bundle resources
doesn't contain box_main

 

box_main.png 로 바꿔도 같은 에러. 이렇게 저렇게 하다가 찾아보니

Cocos Creator 3.x 에서는 이미지 하나에 서브 애셋이 자동으로 붙는데

보통 spriteFrame 이나 texture 가 붙는다고 한다.

그래서 원하는 대로 로드하기 위해서는 /spriteFrame 을 붙여서 로드해야 한다.

비슷한 문제를 또 만날 거 같아서 포스팅.

const sf = await new Promise<SpriteFrame>((res, rej) => {
resources.load('box_mainui_03/spriteFrame', SpriteFrame, (e, f)=> e ? rej(e) : res(f));
});

 

 

이렇게 고쳐서 로드하니 잘된다.

그렇게 띄운 이미지 ㅋ

 

이런 자잘 한것들에서 시간이 걸려서 어느 세월에 다 포팅할 수 있을지 모르겠지만 올해 안에만 할 수 있으면 좋겠다.

반응형