update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator, AssetManager, assetManager, Component, Node, director, Prefab, resources, Sprite, SpriteFrame, Texture2D, v2, SpriteAtlas, ImageAsset, instantiate, AudioClip, Asset, JsonAsset, Material } from 'cc';
|
||||
import { _decorator, AssetManager, assetManager, Component, Node, director, Prefab, resources, Sprite, SpriteFrame, Texture2D, v2, SpriteAtlas, ImageAsset, instantiate, AudioClip, Asset, JsonAsset, Material, VideoPlayer, VideoClip } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ResManager')
|
||||
@@ -156,7 +156,38 @@ export default class ResManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** 改变图片--bundle资源 sprite-frame类型的图片*/
|
||||
changeBundleVideo(spt: VideoPlayer, url: string, packageName: string, cb: Function = null) {
|
||||
if (!spt || !url) return;
|
||||
let spttemp:any = spt
|
||||
spttemp.frameUrl = url
|
||||
let bundle = assetManager.getBundle(packageName);
|
||||
if (bundle){
|
||||
bundle.load(url, VideoClip, (err, res: VideoClip) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return
|
||||
}
|
||||
if (!spt.isValid) {
|
||||
return;
|
||||
}
|
||||
if (spttemp.frameUrl != url) {
|
||||
return;
|
||||
}
|
||||
spt.clip = res;
|
||||
//spt.spriteFrame = res;
|
||||
cb && cb(res);
|
||||
});
|
||||
}else{
|
||||
assetManager.loadBundle(packageName, (err: Error, _bundle: AssetManager.Bundle) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return
|
||||
}
|
||||
this.changeBundleVideo(spt, url, packageName, cb);
|
||||
});
|
||||
}
|
||||
}
|
||||
/** 改变图片--bundle资源 sprite-frame类型的图片*/
|
||||
changeBundleSpriteFrame(spt: Sprite, url: string, packageName: string, cb: Function = null) {
|
||||
if (!spt || !url) return;
|
||||
|
||||
Reference in New Issue
Block a user