Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17124

[Editor Extension] How to set spriteFrame from AssetDB

$
0
0

@FocusCreative wrote:

Hi friends.

I want to make an editor extension and automatically replace some of sprite frames of sprite components in the scene via searching and finding with names corresponding sprite frames from an atlas in asset db.

I used scene walker script in editor extension and managed to find sprites in asset database with queryAssets:

Editor.assetdb.queryAssets( 'db://assets/**\/*', 'sprite-frame', function ( err, results ) {
     Editor.log("URL: " + result.url);
}

And I have managed to get corresponding sprite in the scene:

let scene = cc.director.getScene();
let node = scene.getChildByName("smsg_logo_512_rgb");
let sprite = node.getComponent(cc.Sprite);
sprite.spriteFrame = result; // this doesn't work

But I can’t set spriteframe from the query. How can I do that?

Here is the screenshot:

@slackmoehrle @jare can you help me guys? Thanks.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17124

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>