As shown in, when processing the default orientation of the screen, you can select here. There are four directions in the top, bottom, and left directions.
The planning requirement is that the game uses a horizontal screen, but requires automatic rotation in two directions, as shown in, my settings are as follows.
Default orientation * auto roation indicates that the game supports automatic screen rotation, provided that the mobile phone does not lock the screen rotation function.
Landscape right and landscape left indicate that the mobile phone screen only supports automatic rotation in two directions.
<Ignore_js_op>
Here the problem arises. Since two directions of automatic rotation are set, there must be a default direction. However, the default direction of unity is landscape left, which is the positive direction of the screen to the left of the home phone. Most IOS games are in this direction, but it may be a problem on Android, because there is a return button in the lower left corner of the android screen, if your game is a landscape screen, if your game operation area is in the lower-right corner, it is very likely that the return button will be clicked when the player is playing, and the user experience will be reduced ..
Therefore, if you want to enable the Android version to bring the screen to the right of home by default, you must also support automatic rotation of the horizontal screen .. However, in the Unity panel, automatic rotation is not set and the default direction parameters are set... I thought of assigning values to the code, so I had the following code. It seems that the problem is not solved perfectly, because unity has a boot screen, but the boot screen is executed before awake, so although awake sets the screen direction, however, the orientation of the Start Screen is indeed read from projectsetting.
[Applescript] How can I view the copy code in plain text?
010203040506070809101112131415 |
void Awake ( ) { / / Set the positive direction of the screen to the right of the Home Key Screen.orientation = ScreenOrientation.LandscapeRight; } void Start ( ) { / / Set automatic screen rotation and set the supported orientation Screen.orientation = ScreenOrientation.AutoRotation; Screen.autorotateToLandscapeLeft = true ; Screen.autorotateToLandscapeRight = true ; Screen.autorotateToPortrait = false ; Screen.autorotateToPortraitUpsideDown = false ; } |
Therefore, I directly set the default square direction to the right of the Home button in setting.
<Ignore_js_op>
In the awake or start method, the problem is solved perfectly when it is set to support horizontal screen rotation.
[Applescript] How can I view the copy code in plain text?
123456789 |
void Start ( ) { / / Set automatic screen rotation and set the supported orientation Screen.orientation = ScreenOrientation.AutoRotation; Screen.autorotateToLandscapeLeft = true ; Screen.autorotateToLandscapeRight = true ; Screen.autorotateToPortrait = false ; Screen.autorotateToPortraitUpsideDown = false ; } |
Auto-rotate screen default Rotation