3.5.2
分享一个适配的坑,之前一直用按高度适配和widget没有任何问题。但是用宽度适配就回出现问题,原来是因为按高度适配时canvas的高度会变化,但是摄像机的orthoHeight要自己写脚本去改。
@ccclass('CameraAdapter')
@executionOrder(-1)
export default class CameraAdapter extends Component {
onLoad() {
// 720是设计宽度,不同的话改一下即可
this.node.getComponent(Camera).orthoHeight = 720 * screen.windowSize.height / screen.windowSize.width / 2
}
}