更新ui
This commit is contained in:
@@ -119,12 +119,19 @@ export class SceneBgVideoLayer extends li_BaseView {
|
||||
this.videoPlayer.play();
|
||||
let uiT:UITransform = this.videoPlayer.node.getComponent(UITransform);
|
||||
|
||||
const size = uiT.contentSize;
|
||||
console.log(size);
|
||||
const videoSize = uiT.contentSize;
|
||||
const targetSize = data.size;
|
||||
console.log(targetSize);
|
||||
console.log('Video size:', videoSize, 'Target size:', targetSize);
|
||||
|
||||
this.videoPlayer.node.setScale(new Vec3(targetSize.y/576,targetSize.y/576,1));
|
||||
// 计算宽度和高度的缩放比例
|
||||
const scaleX = targetSize.width / videoSize.width;
|
||||
const scaleY = targetSize.height / videoSize.height;
|
||||
|
||||
// 选择较大的缩放比例以填满整个区域(可能超出但不会有黑边)
|
||||
const scale = Math.max(scaleX, scaleY);
|
||||
|
||||
console.log(`Video scaling: scaleX=${scaleX}, scaleY=${scaleY}, final scale=${scale}`);
|
||||
this.videoPlayer.node.setScale(new Vec3(scale, scale, 1));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user