I'm developing a game that runs on both mobile phones and tablets.
Currently I'm using only the Portrait orientation for all devices but the portrait orientation looks better on phones meanwhile landscape orientation looks better on tablets.
I set "Portrait" option in the Unity's Player Settings > Resolution and Presentation > Default Orientation but I would like to provide a landscape layout for tablets (without affecting phones).
How I can I do that? Is there any why to programmatically set the Screen orientation when the application starts?
You can try Screen.Orientation
In the Start (or Awake) method of a MonoBehaviour that is added to the stage call:
Screen.Orientation = ScreenOrientation.LandscapeRight
Now you just need to check if the device is tablet or phone, I don't know any way out of the box to do this, but you can check the aspect ratio and base your decision on this.
You can check the aspect ratio by getting Screen.width and Screen.height.
Related
I am creating a game for google assistant using actions builder and interactive canvas (Phaser 3 Framework). I have two questions:
How to handle device orientation as most smart displays are in landscape orientation while smartphones are in portrait orientation.
I can create two games, one in portrait mode and another in landscape mode. Is there any way by which I can do conditional loading of interactive canvas game url? for eg: portrait mode game for smartphones and landscape mode game for smart displays?
Please note that I already tried adding multi resolution support in the game but the graphics and design is in such a way that it doesn't look good.
Thanks-in-advance
There's no direct way to do this. One potential workaround you could use is checking if the device supports the actions_capability_web_browser capability, which is only available on phones and not smart displays.
My flutter app only supports portrait mode.
However, on one screen user can take the pic using the camera plugin. Users can take the pic portrait mode or landscape mode(Without changing device orientation).
I want to display a rectangle overlay on top of the camera. So if I can detect the mobile is in landscape or portrait mode I can add x,y, height, width values according to the orientation.
I am not asking about the Orientation builder because my app only supports portrait mode.
I have read some articles about Gyrometer to detect the device orientation. But in flutter, I haven't found code examples.
I'm working on a project with A-Frame. My problem is that when I open from my iPhone (model Xs Max) even the easiest example code moving the device will not change the camera rotation. But when i go to https://aframe.glitch.me/ this one works even if it is the same code. The device motion and orientation is enabled in iPhone settings. What am I missing?
I am developer tizen consumer tv web app.How should i rotate the screen (toggle orientation) by code.
Please help us in this.
Let me know if you need any further information.
Lock the screen with the lockOrientation() method.
The following code snippet demonstrates how to lock the screen to a specified orientation.
screen.lockOrientation("portrait-secondary");
The method accepts the following parameter values: portrait-primary, portrait-secondary, landscape-primary, landscape-secondary, portrait, and landscape.
Note:
When using the screen orientation lock:
When the portrait value is used to lock the orientation, the orientation can change between portrait-primary and portrait-secondary. The landscape value behaves similarly.
Depending on the browser, unlocking the screen orientation may have no visual effect.
For more follow this.
You can use this code for rotate the device form Landscape to portrait .
b2bapis.b2bcontrol.setMenuOrientation("DEGREE_90",onSuccessSettingMenuOrientation,onErrorSettingMenuOrientation);
b2bapis.b2bcontrol.setSourceOrientation("TV","DEGREE_90", onSuccessSettingOrientation, onErrorSettingOrientation);
Note: need to add privileges in config.xml
An iPad app can support inclusion of launch images in both orientations; presumably, if your app supports auto-rotation, then this would suggest to me that if the user launches an app while the device is in Landscape mode, then the Landscape launch image is used.
But in all the apps I've built and released, this has never been the case. Never once has the Landscape launch image appeared, only the Portrait. After loading, the app will auto-rotate to whatever orientation the device is in, but at launch, it assumes you are in Portrait. Always.
Why?
I have seen many other apps in the store that behave this way, but then there are some seem to always automatically know immediately at first launch, from that first launch image, that you are in Landscape, if that's the case.
How is this done?
iPhone supports only portrait images (http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW5)
Apps that don't support portrait orientations, provide the same portrait oriented image. For example, Angry birds on iPhone has the same portrait oriented image but the guys painted rotated graphics on it.
As it would turn out, the issue was due to leaving out the supported orientations in the plist file for the app. You can add these manually or just select them in the Target page. More details here:
How to get a landscape launch image to actually appear when launched?