2D Toolkit Forum
2D Toolkit => Support => Topic started by: Busson 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.
(http://img33.imageshack.us/img33/1416/ihwr.jpg)
-
I´m having the same issue with exporting to Windows Phone 8 :(
-
:-\ works in portrait mode, but not landscape
(http://img838.imageshack.us/img838/7396/soe0.jpg)
(http://img819.imageshack.us/img819/7308/7zis.jpg)
-
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.
-
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 -
[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 -
[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.
-
The fix works like a charm!
Thanks for the quick response. :)
-
worked :D
thank you!
-
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 :/
Foreground="{StaticResource PhoneForegroundBrush}" Orientation="Landscape" SupportedOrientations="Landscape" BackKeyPress="PhoneApplicationPage_BackKeyPress" OrientationChanged="PhoneApplicationPage_OrientationChanged">
-
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.