playMaker

Author Topic: Change device orientation action  (Read 9747 times)

jpsmarinho

  • Playmaker Newbie
  • *
  • Posts: 11
Change device orientation action
« on: October 29, 2013, 09:20:32 PM »
Hi,


To me, its important to force the change of the device orientation in runtime ( My main menu runs in landscape and the entire game in portrait ). So, anyone have the ability to create this action? please? To tell the truth, I tried use script to do this but I fail with the message that Portrait is not member of ScreenOrientation.... Thanks!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: Change device orientation action
« Reply #1 on: October 30, 2013, 01:43:07 AM »
Hi,

 Can you share the reference to the script you are using or paste it here. It's likely that you use an obsolete version for 3.x

bye,

 Jean

jpsmarinho

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Change device orientation action
« Reply #2 on: October 30, 2013, 08:30:29 AM »
Hi Jean!

I'm using this :

// Start in landscape mode
   function Start () {
      Screen.orientation = ScreenOrientation.LandscapeLeft;
   }

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: Change device orientation action
« Reply #3 on: October 30, 2013, 08:38:07 AM »
Hi,

 there is no "portrait" reference in the code you paste, so you can't get an error on this. Can you double check?


http://docs.unity3d.com/Documentation/ScriptReference/ScreenOrientation.html

bye,

 Jean

jpsmarinho

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Change device orientation action
« Reply #4 on: October 30, 2013, 08:53:09 AM »
Sorry! This is my code:

using UnityEngine;
using System.Collections;

public class ScreenOrientation : MonoBehaviour {
   // Use this for initialization
   void Start () {
      if(Application.loadedLevelName.Equals( "MainMenu")){
         Screen.orientation = ScreenOrientation.LandscapeLeft;
      }
      
      else if (Application.loadedLevelName.Equals( "ScreenOrientation")){
         Screen.orientation = ScreenOrientation.AutoRotate;
      }
      
      else if (Application.loadedLevel.Equals( "SecondLayer") ){
         Screen.orientation = ScreenOrientation.Portrait;   
      }
   
   }
}


And in the image is the error.


What I need is an orientation in Menu, and other orientation in the game.

jpsmarinho

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Change device orientation action
« Reply #5 on: October 31, 2013, 02:15:08 PM »
Jean, my problem was solved!

The problem was the directory of the script. I moved the file to the root in my project and this worked! Its because in the root is compiled first right? Thanks!!

jpsmarinho

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Change device orientation action
« Reply #6 on: October 31, 2013, 02:32:50 PM »
No, the problem persist...

Its work in a blank project

 Screen.orientation = ScreenOrientation.Landscape;

but in my project give me error.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: Change device orientation action
« Reply #7 on: October 31, 2013, 02:57:04 PM »
Hi,

 very odd... What error do you get now?

bye,

 Jean

jpsmarinho

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Change device orientation action
« Reply #8 on: November 01, 2013, 10:10:39 AM »
Sorry for my late answer!!

And sorry to all about that. My error is noob. ^^

The error was in the name of the script! I named ScreenOrientation. I think with this has some conflict...

But, its really solved!

Thanks!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: Change device orientation action
« Reply #9 on: November 01, 2013, 11:57:18 AM »
Hi,

Good, i did not pay attention to the name, and yes, tgat was the problem indeed.

Bye,

Jean

gsmetzer

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Change device orientation action
« Reply #10 on: August 01, 2014, 08:18:30 PM »
Is there a way to do this during runtime?  Would an action work?   It would be great if midway during runtime I could switch the orientation with a new state.
« Last Edit: August 01, 2014, 08:36:02 PM by gsmetzer »

gsmetzer

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Change device orientation action
« Reply #11 on: August 04, 2014, 01:14:09 PM »
I've tried to use the above script but keep getting a
 'ScreenOrientation' does not contain a definition for 'LandscapeLeft'

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: Change device orientation action
« Reply #12 on: August 06, 2014, 06:32:12 AM »
Hi,

 ok, please find an action that will allow you to change the device orientation.

 If that works for you let me know, I'll advertize for it on the rss.

 Bye,

 Jean

gsmetzer

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Change device orientation action
« Reply #13 on: August 06, 2014, 02:32:30 PM »
Thanks Jean,

I got it to work only when I made a build on to my iOS device.   It doesn't change in the editor and so doesn't switch in UnityRemote4 either.
 This is fine for my use for now.  If it had the additional functionality of switching the editor that would be helpful as I develop but I can work around it.
Thanks for making it an action!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15602
  • Official Playmaker Support
Re: Change device orientation action
« Reply #14 on: August 07, 2014, 05:23:00 AM »
Hi,

 yep, this is a Unity restriction, you can't do that even outside PlayMaker, changing device orientation is only available on the device. I would so love that they build it in the editor ( cause it's possible of course, only that it needs to be deeply integrated).

 Bye,

 Jean