xamarin / urho

Code to integrate with the Urho3D engine
Other
462 stars 122 forks source link

UrhoSurface.RunInActivity() always uses landscape orientation on Android #203

Closed iainmerrick closed 7 years ago

iainmerrick commented 7 years ago

While learning UrhoSharp, I figured I would update SamplyGame.Droid to use this new simple startup method. However, it always runs in landscape mode and I can't see a way to make it use portrait.

Looking at the source, the RunInActivity() method uses a new Intent to launch UrhoActivity, which has no attribute annotations. However, the following line is merged into AndroidManifest.xml:

<activity android:name="org.libsdl.app.UrhoActivity"
  android:configChanges="keyboardHidden|orientation"
  android:label="UrhoSharp activity"
  android:screenOrientation="landscape"
  android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>

In fact the same line is added twice! I can't see where in the build process that happens, but I'd love to know.

UrhoActivity should either inherit the orientation of the calling activity, or check the value of ApplicationOptions.Orientation.

EgorBo commented 7 years ago

Done! RunInActivity now respects ApplicationOptions.Orientation property, However, a better approach is to use UrhoSurface directly in your own activity in order to have more control over it (UrhoSurface doesn't have "orientation" issues). The line "android:screenOrientation="landscape"" was inserted to the final AndroidManifest.xml by sdl-release.aar lib.