C# 如何检查Android设备在Unity中的自动旋转方向?
我正在为android创建一个简单的插件。我只想在Unity侧使用C#设置方向 我正在使用此代码检查屏幕的方向C# 如何检查Android设备在Unity中的自动旋转方向?,c#,android,unity3d,C#,Android,Unity3d,我正在为android创建一个简单的插件。我只想在Unity侧使用C#设置方向 我正在使用此代码检查屏幕的方向 if (Screen.orientation == ScreenOrientation.Portrait) { // portrait } else { // landscape } 但是我正在寻找的代码中缺少了一些东西。因为还有自动旋转模式。我无法检查这种情况。有人能帮我通过Unity for Android设备检查自动旋转模式吗 谢谢 if (Screen.orientation
if (Screen.orientation == ScreenOrientation.Portrait) {
// portrait
}
else
{
// landscape
}
但是我正在寻找的代码中缺少了一些东西。因为还有自动旋转模式。我无法检查这种情况。有人能帮我通过Unity for Android设备检查自动旋转模式吗
谢谢
if (Screen.orientation == ScreenOrientation.Portrait) {
// Portrait
}
else if (Screen.orientation == ScreenOrientation.PortraitUpsideDown)
{
// Portrait upside down
}else if (Screen.orientation == ScreenOrientation.LandscapeLeft)
{
// Landscape Left
}else if (Screen.orientation == ScreenOrientation.LandscapeRight)
{
// Landscape Right
}else if (Screen.orientation == ScreenOrientation.AutoRotation)
{
// AutoRotation
}
如果你不在乎正面向下的肖像,左边或右边的风景,你可以做
if (Screen.orientation == ScreenOrientation.Portrait || Screen.orientation == ScreenOrientation.PortraitUpsideDown) {
// Portrait
}else if (Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight)
{
// Landscape
}else if (Screen.orientation == ScreenOrientation.AutoRotation)
{
// AutoRotation
}
包括自动旋转检查,并且您的代码也固定为检测其他旋转。有关更多信息,请阅读Unity文档。
请随意使用以检查设备方向
在记住之前的状态时,你可以自己触发旋转事件