flutter-unity-view-widget
flutter-unity-view-widget copied to clipboard
Unity calls screen rotation, white screen on iOS
Describe the bug Unity script call Screen. orientation=ScreenOrientation. LandscapeLeft; Rotate the screen, Invalid on iOS phone with white screen, normal on Android
To Reproduce Steps to reproduce the behavior: 1:In unity script create a button call Screen.orientation = ScreenOrientation.LandscapeLeft; 2:export ios(release) 3:running in flutter
Expected behavior A clear and concise description of what you expected to happen.
Screenshots
Unity (please complete the following information):
- OS: redmi k60 pro
- Version :13
Smartphone (please complete the following information):
- Device: iphone 14 pluse
- OS: ios
- Version 16.6
Additional context Add any other context about the problem here.
Try giving some time after rotating the screen, f.e. 2 seconds and then call .resume() on unityWidgetController
Hi,
I'm getting this same white screen issue when using Screen. orientation=ScreenOrientation. LandscapeLeft; in IOS.
And I have called .resume() method in unityWidgetController also. It is not working.
Is there any other solution to fix this issue?
Can any of you share details like Unity version and Flutter version?
I think I skipped this one earlier because crucial data like that was missing.
Please try using the latest Unity 2021 or 2022 version and report back.
Some unity versions have a lot of bugs in iOS screen rotation. For example the 2021.3.28 changelog contains 3 separate messages for rotation fixes. And checking others, it is far from the only one.
Hi @timbotimbo
I'm using this, Unity version : 2021.3.11f1 Flutter version : 3.3.10
When generating build from Unity iOS module, orientation is working fine.
But when generating iOS build after integrating unity with flutter, I'm getting white screen issue.
Hi @timbotimbo
I'm facing this issue in my current project. If you provide any solution for this, it'll be very useful for us.
@Kiruthika2206 For us giving two second time in onUnityCreated and then calling .resume() worked.
Future<void> onUnityCreated(UnityWidgetController controller) async { await Future.delayed(Duration(milliseconds: 2000)); await _unityWidgetController.resume(); ...
Hi @maciej-szulc
I have added the code provided by you in my project. But still I'm getting white screen.
I have added one button action in unity. When user clicks on that button Screen. orientation=ScreenOrientation.AutoRotation; this code will trigger. On that time we are getting white screen in iOS.
@Kiruthika2206 I understand that when you change the screen orientation, you also rebuild the entire widget in Flutter that contains FlutterUnityWidget?
@maciej-szulc Yes widget is rebuilding when change orientation button action triggered.
Just wanted to confirm that we encountered the same issue embedding the Lightship example project https://github.com/niantic-lightship/ardk-samples/ into our flutter app for testing the various ARDKs etc.
On first load the main menu scene would appear white. If we changed the build order to load any of the others scenes first, everything worked fine.
if we loaded another scene after gettting the white screen, everything worked ok.
We found that in https://github.com/niantic-lightship/ardk-samples/blob/ff7a7f20817a71b1d4f9bb5fe8176a5f17f274e1/Assets/Samples/Common/Scripts/VersionRead.cs#L15 they have the line ...
void Awake(){
Screen.orientation = ScreenOrientation.Portrait;
}
god knows why they have this in VersionRead.cs
Removing this offending line made everything work ticketyboo. I haven't checked to see if having this line somewhere else, in combinatino with the delayed resume() code as suggested makes any difference. I'll be sure to post if we come across this issue again. Needless to say, our issue was moreover someone adding spurios code to completely unrelated scripts. VersionRead does not need to call screen orientation ffs.