Is this supported in 3.x? In 2.x it was set on every scene’'s Canvas component.
In 3.x this setting is global along with fitWidth/fitHeight?
This is needed if we have both portrait/landscape scenes in runtime.
Is this supported in 3.x? In 2.x it was set on every scene’'s Canvas component.
In 3.x this setting is global along with fitWidth/fitHeight?
This is needed if we have both portrait/landscape scenes in runtime.
import { _decorator, Component, Node, view, ResolutionPolicy } from ‘cc’;
const { ccclass, property } = _decorator;
export class CanvasSizeMgr {
public static setContentStrategy() {
if (view.getFrameSize().width / view.getFrameSize().height > 1.7) {
// console.log(`适配高`);
view.setDesignResolutionSize(view.getDesignResolutionSize().width, view.getDesignResolutionSize().height, ResolutionPolicy.FIXED_HEIGHT);
}
else {
// console.log(`适配宽`);
view.setDesignResolutionSize(view.getDesignResolutionSize().width, view.getDesignResolutionSize().height, ResolutionPolicy.FIXED_WIDTH);
}
console.log(view.getResolutionPolicy());
}
}
view.setDesignResolutionSize(view.getDesignResolutionSize().width, view.getDesignResolutionSize().height, ResolutionPolicy.FIXED_WIDTH);