This commit is contained in:
2025-08-01 18:28:36 +08:00
parent f91430728f
commit 0f8902405d
97 changed files with 6650 additions and 3608 deletions
+33 -2
View File
@@ -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;