unity小游戏如何动态转屏?
设置 启动竖屏的情况,通过调用 SetDeviceOrientation,动态转横屏会出现这样的效果。 [图片] [图片] 设置 启动横屏的情况,通过调用 SetDeviceOrientation,动态转竖屏会出现这样的效果。 [图片] [图片] public void SetLandscapeMode()
{
#if UNITY_WEBGL && !UNITY_EDITOR
// 微信小游戏环境
SetDeviceOrientationOption option = new SetDeviceOrientationOption
{
value = "landscape",
success = (res) =>
{
},
fail = (res) =>
{
}
};
WX.SetDeviceOrientation(option);
#else
Screen.orientation = ScreenOrientation.LandscapeLeft;
#endif
mainCanvasScaler.referenceResolution = new Vector2(1280, 720);
mainCanvasScaler.matchWidthOrHeight = 1;
}
public void SetPortraitMode()
{
#if UNITY_WEBGL && !UNITY_EDITOR
// 微信小游戏环境
SetDeviceOrientationOption option = new SetDeviceOrientationOption
{
value = "portrait",
success = (res) =>
{
},
fail = (res) =>
{
}
};
WX.SetDeviceOrientation(option);
#else
Screen.orientation = ScreenOrientation.Portrait;
#endif
mainCanvasScaler.referenceResolution = new Vector2(720, 1280);
mainCanvasScaler.matchWidthOrHeight = 0;
}
以上的具体代码片段,是我的调用有问题还是微信小游戏unity插件的bug?