Multiple design resolution

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());

}

}

1赞

view.setDesignResolutionSize(view.getDesignResolutionSize().width, view.getDesignResolutionSize().height, ResolutionPolicy.FIXED_WIDTH);

1赞

You can refer to this code:
https://github.com/cocos/cocos-awesome-tech-solutions/blob/04caf29e397c5aef5a6ff81e07a12c3a9671614a/demo/Creator3.4.0_2D_ScreenSwitch/assets/NewComponent.ts#L35

1赞