Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do i force a game to run in landscape mode?

Discussion in 'Editor & General Support' started by Wrenger, May 17, 2020.

  1. Wrenger

    Wrenger

    Joined:
    Apr 28, 2020
    Posts:
    71
    For example, knife hit is locked in portrait mode, how can i lock a game in landscape mode?
     
  2. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    ow3n likes this.
  3. Wrenger

    Wrenger

    Joined:
    Apr 28, 2020
    Posts:
    71
    Is that the equivalent of this? upload_2020-5-19_16-55-17.png
     
    SolarHash and firatlahur like this.
  4. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Well, not exactly, what you configure on the `Player Settings` options that you're pointing out on your screenshot is for choosing the default orientation and also for locking certain orientations that your game or app doesn't support.

    The link that I sent to you is to change the screen orientation in runtime, depending on the specific needs of your game or app in a certain moment or situation. For example, you maybe want to have some sections to be in portrait mode and some others in landscape.


    I hope this helps!
     
    Bhaumik78 likes this.
  5. Wrenger

    Wrenger

    Joined:
    Apr 28, 2020
    Posts:
    71
    Yep it does. Ty
     
    DiegoDePalacio likes this.
  6. EYUMIX1

    EYUMIX1

    Joined:
    Jul 31, 2020
    Posts:
    1
    where do i put the script
     
  7. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Hi @EYUMIX1,

    It depends on your project, but ideally, the code should run when the scene that you want to have with certain orientation loads. You can also run the code in the same scene if you need it.

    For example, if you have a system in charge of loading and unloading scenes, you can place the code in the related script.

    In any case, it's a good practice to show a loading screen on top if you want to avoid the user to see the hard transition between orientations.


    I hope it helps!
     
    AakashDP likes this.
  8. kloogens

    kloogens

    Joined:
    Jul 1, 2015
    Posts:
    107
    I have a game with Standalone and Android target platforms.

    In my standalone build, the Screen.Orientation is ALWAYS portrait no matter what.
    This is a problem because I have different layouts based on screen orientation.
    It works fine for Android but not for standalone.

    So the standalone version is laying out everything as if it is portrait when it should be landscape.

    My monitor is 1920x1080 which sounds like landscape to me

    Setting For standalone build:
    standalone.jpg


    Setting for Android:
    android.jpg

    I've been messing with these settings for hours and nothing works.
    I am beyond frustrated on this, can anyone please explain it?


    Of course in the editor, it works as expected.