Change device orientation at runtime

I’m using Cocos Creator 3.7.2.

I want to switch device orientation (android/ios) to portrait or landscape in some scene. I had google some topic, but not found solution from Cocos Creator.

Then, I tried to change some code from Java side

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT )

But end up cause crash app with error

CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/engine/Engine.cpp:328: bool cc::Engine::redirectWindowEvent(const cc::WindowEvent &): assertion "w" failed

Anyone face the same problem?

1 Like

Hi nguyen991,

Dis you find any solution for this? Actually I was facing the same issue.