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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to detect screen orientation when I just support one orientation

Discussion in 'Scripting' started by itachi4365, May 28, 2014.

  1. itachi4365

    itachi4365

    Joined:
    Sep 24, 2012
    Posts:
    40
    My game is meant to be played in Portrait mode only but it has some features which I want to activate when the user holds it in other screen orientations. Is there a way to detect that?
     
  2. laurelhach

    laurelhach

    Joined:
    Dec 1, 2013
    Posts:
    229
    Hello,

    and
    I am not quite sure if you want to support both orientation or not. But You know you can force the game to have only one orientation. This is in the options of your build settings. Is it what you asked for?
     
  3. wccrawford

    wccrawford

    Joined:
    Sep 30, 2011
    Posts:
    2,039
  4. itachi4365

    itachi4365

    Joined:
    Sep 24, 2012
    Posts:
    40
    Thanks for the reply.
    @laurelhach: I want the game to be played only in portrait orientation, but its a puzzle game where, when you hold the phone in different orientation you see the missing pieces, so I just want to detect the orientation the user is holding the phone in. And I knew about the options in the build setting.

    @wccrawford; Thanks for the link.

    Although I have found that the device orientation is also given through Input.deviceOrientation. But its gives out the position in very specific way, I mean your phone has to be at a particular angles for it to give the output, so I will have to write some custom code.