放在internal-> image里的default_sprite_splash资源要怎么在脚本里取得?
不要用@property的方式,
我有想到可以直接在电脑上复制一份放到其他目录用bundle.load,但感觉怪怪的,明明是预设资源,应该要有可以直接拿到的方法才对,新手发问请见谅。
放在internal-> image里的default_sprite_splash资源要怎么在脚本里取得?
不要用@property的方式,
我有想到可以直接在电脑上复制一份放到其他目录用bundle.load,但感觉怪怪的,明明是预设资源,应该要有可以直接拿到的方法才对,新手发问请见谅。
我也想知道
终于试出来了,但是这个只在编辑器里有效。
我解决了我的问题,我要写组件时希望能生成带默认spriteFrame
的sprite
,用在编辑过程中。
这个方法在游戏运行时应该就不行了。
function _setDefaultSpf(sp: cc.Sprite) {
if (!CC_DEV) return;
let url = 'db://internal/image/default_sprite_splash.png/default_sprite_splash';
Editor.assetdb.queryAssets(url, "sprite-frame", (err, ress) => {
if (!err) {
if (ress.length > 0) {
cc.loader.load({ uuid: ress[0].uuid }, (err, spf) => {
if (!err) {
cc.log("加载>>", spf);
sp.spriteFrame = spf
}
});
} else {
cc.log("没有资源");
}
}
});
}
希望能帮到你
internal资源慎用,会导致在原生平台开启动态合图之后出脚本错,而且很难查