Search Unity

Mobile Development

Discussion in 'Scripting' started by boowman, Jul 22, 2014.

  1. boowman

    boowman

    Joined:
    Jan 3, 2014
    Posts:
    57
    Can I set a scene to a certain Orientation like Portrait and when I change to a different scene to change to Landscape.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    In a script in either scene, you can change Screen.orientation in the Start method.

    So it's easy technically, but I'd be careful about actually doing it. I can't think of anytime I would force a user to be in one orientation in one scene and a different orientation in another scene - it'd be very poor user experience ("ugh, I just turned my phone the other way. What do you want, game!?") Possibly consider redesigning one scene or the other so that users don't have to rotate their phones more than just when they enter your app.
     
  3. boowman

    boowman

    Joined:
    Jan 3, 2014
    Posts:
    57
    Basically the main menu will be in portrait and when playing in landscape
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Yeah, that's exactly what I'm referring to. That's gonna annoy your users - it'd certainly annoy me. Why not make your menu work in landscape?
     
  5. boowman

    boowman

    Joined:
    Jan 3, 2014
    Posts:
    57
    It works but the only problem is that when I change from game back to main menu the buttons are in landscape instead of portrait.
     
  6. boowman

    boowman

    Joined:
    Jan 3, 2014
    Posts:
    57
    Because it's already done.
    I haven't thought this through, this is my first game so there are a lot of thinks that I haven't thought about.
     
  7. boowman

    boowman

    Joined:
    Jan 3, 2014
    Posts:
    57
    Oh nevermind, I think I know what that is happening. It's because I am using screen width and height to determin the buttons sizes and positions and I am calling that in awake.
     
  8. boowman

    boowman

    Joined:
    Jan 3, 2014
    Posts:
    57
    I didn't multiple things and none of them worked. I am thinking to store the screen width and height in a script and when I go back to portrait to get the size from a different script.