mirror of
https://github.com/szrpf/SceneAdapterDemo
synced 2025-10-25 00:15:55 +00:00
v1.2
This commit is contained in:
@@ -122,7 +122,7 @@
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
0.31666666666666665
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
@@ -643,7 +643,7 @@
|
||||
"width": 1080,
|
||||
"height": 1920
|
||||
},
|
||||
"_fitWidth": true,
|
||||
"_fitWidth": false,
|
||||
"_fitHeight": false,
|
||||
"_id": "6d1ebIvmZJPqKflif+HTsU"
|
||||
},
|
||||
@@ -655,6 +655,6 @@
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_id": "e7Qc+zZkdDeabOFueN7izj"
|
||||
"_id": "b6/k9iZ/BOq7igiEs0QR6w"
|
||||
}
|
||||
]
|
||||
@@ -9,8 +9,20 @@ const { ccclass, menu } = cc._decorator;
|
||||
@ccclass
|
||||
@menu('Comp/SceneAdapter')
|
||||
export default class SceneAdapter extends cc.Component {
|
||||
|
||||
protected onLoad() {
|
||||
let cvs = this.node.getComponent(cc.Canvas);
|
||||
if (cvs === null) {
|
||||
cc.warn(`节点${this.node.name}没有cc.Canvas组件, SceneAdapter添加失败!`);
|
||||
this.destroy();
|
||||
return;
|
||||
}
|
||||
if (cvs.designResolution.width < cvs.designResolution.height) {
|
||||
cvs.fitWidth = true;
|
||||
cvs.fitHeight = false;
|
||||
} else {
|
||||
cvs.fitWidth = false;
|
||||
cvs.fitHeight = true;
|
||||
}
|
||||
this.resize();
|
||||
cc.view.setResizeCallback(this.resize.bind(this));
|
||||
}
|
||||
@@ -28,4 +40,4 @@ export default class SceneAdapter extends cc.Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user