Search Unity

Question Google Play Services notification choose orientation

Discussion in 'Authentication' started by Spirit_Warrior, Mar 14, 2023.

  1. Spirit_Warrior

    Spirit_Warrior

    Joined:
    Jan 1, 2020
    Posts:
    16
    Hello, after few days of watching tutorials on how to implement Google Play Services in my game I finally manage to make it work, at least the first step.

    Sign in and test an achievement I made.

    And because this is my first game I found my self on a "problem" more or less.
    The game is oriented in Landscape Right but the game when you play it is on vertical like portrait.
    In short my game that is played vertical was developed in Landscape Right mode, the camera, all canvases, configs is for that.

    So when I play my game the achievements it shows on left side (because of Landscape Right) default orientation, but I need to show the UI only on portrait if possible.

    I can't modify the game now to portrait because will break a lot of things.
    I asked chatGPT and suggest me:

    <activity
    android:name=".MainActivity"
    android:screenOrientation="sensorPortrait">

    and

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    But I don't understand it very well, or where do I need to modify and add this new lines.

    So the game remains on landscape right but notifications show them in portrait.

    Any suggestions ?
     
  2. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    Make sure you have your orientation set in Project Settings > Player
    upload_2023-3-15_11-10-36.png
     
  3. Spirit_Warrior

    Spirit_Warrior

    Joined:
    Jan 1, 2020
    Posts:
    16
    I already have it like that, the problem is that the game when you play it is viewed on vertical portrait, so the notifications UI from google play services comes from left side, while you playing on vertical.
    I need to show GPS UI in vertical portrait mode (Green Box), while the game remains in landscape right.

     
    Last edited: Mar 15, 2023
  4. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    I'm slightly confused, are you saying that the game is already landscape, but is showing portrait and you're wondering why the notifications are coming out landscape?

    If so, then that's the answer, run the entire game either in Portrait or Landscape.
     
  5. Spirit_Warrior

    Spirit_Warrior

    Joined:
    Jan 1, 2020
    Posts:
    16
    That's the point, the game is already setted in landscape mode but when you play the game was designed as Vertical to play, the problem is notifications and UI of google play services shows as landscape too.

    That's what I'm trying to figure out to show only UI in portrait mode while game remains in landscape to show correctly the game.

    (other solution much more tedious will be to refactor the game a lot, to be in portrait from beginning but there is to much to change, scenes, a lot of canvases and specific orientation. )

    Here is an example of UI GPS.
     
  6. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    Unfortunately there's no possible solution to what you are trying to do.

    The way you have your orientation set out to be set in landscape, but plays in portrait mode is a little unconventional, I'd try to shift to either landscape or portrait, that way, the devices system UI will follow the orientation of the game.
     
  7. Spirit_Warrior

    Spirit_Warrior

    Joined:
    Jan 1, 2020
    Posts:
    16
    Thanks for the answer,
    I looked on google with multiple pages and tutorials, nothing, also I asked chatGPT and suggested me to use this code on AndroidManifest:

    Code (CSharp):
    1. <activity android:name="com.google.games.bridge.NativeBridgeActivity"
    2.           android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
    3.           android:screenOrientation="portrait" />
    But for me didn't work, I post it here maybe, will work for other people.

    In the end I had to change my game to Portrait and with help from a friend , helped to solve de orientation canvases that messed up everything and also the controls of the players.

    Thanks for helping!
     
    Julian-Unity3D likes this.
  8. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    It's interesting to see people use ChatGPT however, please remember it only has information for what has been and what was, I'd advise writing the code first and then seeing if ChatGPT can help further optimise it.

    Glad to hear you now have it working though.
     
    Spirit_Warrior likes this.