Auto-rotate screen default Rotation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.