Hello Guest

Author Topic: Landscape Orientation Problem - WP8 Project  (Read 9143 times)

Busson

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Landscape Orientation Problem - WP8 Project
« on: July 24, 2013, 02:19:27 am »
Hello,

I configured the orientation of my project as landscape, but tk2dcamera remains in portrait orientation . See the image below:

With the camera's Unity works. This project is running on a Windows Phone 8.


idloco

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Landscape Orientation Problem - WP8 Project
« Reply #1 on: July 24, 2013, 05:19:33 am »
I´m having the same issue with exporting to Windows Phone 8  :(

Busson

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Landscape Orientation Problem - WP8 Project
« Reply #2 on: July 24, 2013, 01:48:46 pm »
 :-\ works in portrait mode, but not landscape




nikhilf

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Landscape Orientation Problem - WP8 Project
« Reply #3 on: July 25, 2013, 11:38:28 am »
I am facing the same issue.
I tried to add a Unity Camera on top of the tk2dcamera after which works fine.
But I want it to work with the tk2dcamera itself.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Landscape Orientation Problem - WP8 Project
« Reply #4 on: July 25, 2013, 11:40:14 am »
After a bit of investigation, it looks like this is a problem specific to WP8 - Unity is performing the rotation by modifying the projection matrix :(
You can work around it by adding this in tk2dCamera:

2DTOolkit 1.9x / 2.0 -
Code: [Select]
[b]if (Application.platform == RuntimePlatform.WP8Player &&
    (Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight))
   {
    float angle = (Input.deviceOrientation == DeviceOrientation.LandscapeRight) ? 90.0f : -90.0f;
    Matrix4x4 m2 = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one);
    m = m2 * m;
   }
[/b]
                if (mainCamera.projectionMatrix != m) {
mainCamera.projectionMatrix = m;
}

2DToolkit 2.1 -
Code: [Select]
[b]if (Application.platform == RuntimePlatform.WP8Player &&
    (Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight))
   {
    float angle = (Input.deviceOrientation == DeviceOrientation.LandscapeRight) ? 90.0f : -90.0f;
    Matrix4x4 m2 = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one);
    m = m2 * m;
   }
[/b]
if (unityCamera.projectionMatrix != m) {
unityCamera.projectionMatrix = m;
}


This doesn't handle all the possibilities properly, as there is no way to find out what the user has selected in the build settings at runtime, but will be a good place to start.
« Last Edit: August 17, 2013, 12:40:54 pm by unikronsoftware »

nikhilf

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Landscape Orientation Problem - WP8 Project
« Reply #5 on: July 25, 2013, 01:33:59 pm »
The fix works like a charm!
Thanks for the quick response.  :)

Busson

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Landscape Orientation Problem - WP8 Project
« Reply #6 on: July 25, 2013, 03:35:39 pm »
worked  :D

thank you!

cesarpo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Landscape Orientation Problem - WP8 Project
« Reply #7 on: August 17, 2013, 04:40:21 am »
 I had the same problem. and adding this code fixes the error, but still the tk2dCamera responds to the Portrait orientation, how can I do to only support Landscape modes?

edit

I had to edit the MainPage.xaml and set the SupportedOrientations="Landscape" attribute. This seems to be independent of the player configuration in the project settings :/

Code: [Select]
    Foreground="{StaticResource PhoneForegroundBrush}" Orientation="Landscape" SupportedOrientations="Landscape" BackKeyPress="PhoneApplicationPage_BackKeyPress" OrientationChanged="PhoneApplicationPage_OrientationChanged">
« Last Edit: August 17, 2013, 04:53:05 am by cesarpo »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Landscape Orientation Problem - WP8 Project
« Reply #8 on: August 17, 2013, 12:42:22 pm »
I forgot to post an updated fix. Input.screenOrientation should be Screen.orientation instead. This respects the configuration in Unity. I've updated the code above with the required changes.