This commit is contained in:
richarjiang
2026-03-11 09:04:33 +08:00
commit 02a67909d6
33 changed files with 1877 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "8c0af393-af1b-47f5-83aa-48f638d0156d",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,27 @@
import { _decorator, Component, UITransform, view } from 'cc';
const { ccclass, menu, disallowMultiple } = _decorator;
@ccclass('BackgroundScaler')
@menu('Nexux/BackgroundScaler')
@disallowMultiple()
export class BackgroundScaler extends Component {
onLoad() {
const bg = this.node;
const uiTransform = bg.getComponent(UITransform);
const bgSize = uiTransform?.contentSize;
if (!bgSize) {
console.error('BackgroundScaler: bgSize is null');
return;
}
const winSize = view.getVisibleSize();
const scaleX = winSize.width / bgSize.width;
const scaleY = winSize.height / bgSize.height;
const scale = Math.max(scaleX, scaleY);
bg.setScale(scale, scale);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "d33b066b-2902-4468-a658-3763de83e0bf",
"files": [],
"subMetas": {},
"userData": {}
}