更新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));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
import { _decorator, Label, Node, Sprite, VideoPlayer, instantiate } from "cc";
|
||||
import {
|
||||
_decorator,
|
||||
Label,
|
||||
Node,
|
||||
Sprite,
|
||||
VideoPlayer,
|
||||
instantiate,
|
||||
UITransform,
|
||||
} from "cc";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
||||
import { DetailImageItem } from "../../uiitems/DetailImageItem";
|
||||
@@ -71,6 +79,39 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
this.avatarVideo.play();
|
||||
}
|
||||
}
|
||||
|
||||
adjustVideoScale() {
|
||||
if (!this.avatarVideo || !this.avatarVideo.node.parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const tryAdjustScale = () => {
|
||||
const parentTransform =
|
||||
this.avatarVideo.node.parent.getComponent(UITransform);
|
||||
const videoTransform = this.avatarVideo.node.getComponent(UITransform);
|
||||
|
||||
if (parentTransform && videoTransform && videoTransform.height > 0) {
|
||||
const scale = parentTransform.height / videoTransform.height;
|
||||
this.avatarVideo.node.setScale(scale, scale, 1);
|
||||
console.log(`Video scaled to: ${scale}, parent height: ${parentTransform.height}, video height: ${videoTransform.height}`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// 立即尝试一次
|
||||
if (!tryAdjustScale()) {
|
||||
// 如果失败,延迟尝试
|
||||
this.scheduleOnce(() => {
|
||||
if (!tryAdjustScale()) {
|
||||
// 再次延迟尝试
|
||||
this.scheduleOnce(() => {
|
||||
tryAdjustScale();
|
||||
}, 0.5);
|
||||
}
|
||||
}, 0.1);
|
||||
}
|
||||
}
|
||||
nameKey: string;
|
||||
tagKey: string;
|
||||
category;
|
||||
@@ -90,6 +131,14 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
dataDetail.pics[0],
|
||||
"Chat18x"
|
||||
);
|
||||
|
||||
// 添加视频加载完成回调
|
||||
this.avatarVideo.node.on(VideoPlayer.EventType.READY_TO_PLAY, () => {
|
||||
this.adjustVideoScale();
|
||||
}, this);
|
||||
|
||||
// 也立即尝试调整(以防已经加载完成)
|
||||
this.adjustVideoScale();
|
||||
}
|
||||
if (dataDetail.pics.length > 1) {
|
||||
for (let i = this.imgsLayout.children.length - 1; i >= 0; i--) {
|
||||
|
||||
@@ -45,7 +45,7 @@ export class ThemePanel extends li_BaseView {
|
||||
this.registerListener();
|
||||
this.itemInst = this._nodeTab.ThemeItem.getComponent(ThemeItem);
|
||||
this.itemInst.node.active = false;
|
||||
this.content = this._nodeTab.AllThemesLayout;
|
||||
this.content = this._nodeTab.allThemecontent;
|
||||
|
||||
this.Show();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ const { ccclass, property } = _decorator;
|
||||
export class ThemeItem extends Component {
|
||||
@property(Sprite)
|
||||
lockImg: Sprite;
|
||||
@property(Sprite)
|
||||
lockCover: Sprite;
|
||||
@property(Label)
|
||||
titleName: Label;
|
||||
|
||||
@@ -35,7 +37,8 @@ export class ThemeItem extends Component {
|
||||
}
|
||||
|
||||
refresh(themeData: Theme) {
|
||||
this.lockImg.node.active = !themeData.isRelease;
|
||||
this.lockImg.node.active = this.lockCover.node.active =
|
||||
!themeData.isRelease;
|
||||
this.isLocked = !themeData.isRelease;
|
||||
this.key = themeData.key;
|
||||
this.titleName.string = LanguageUtils.getText(themeData.key);
|
||||
|
||||
@@ -36,6 +36,10 @@ export enum Category {
|
||||
* 卡通
|
||||
*/
|
||||
cartoon = 5,
|
||||
/**
|
||||
* 未完成
|
||||
*/
|
||||
upcomming = 6,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user