juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.09k stars 504 forks source link

Unity Scene Flashes then Displays White Screen in Flutter App #947

Closed choji-160 closed 2 months ago

choji-160 commented 2 months ago

Description When integrating Unity with Flutter using the flutter-unity-view-widget, the Unity scene loads for a brief moment and then turns into a white screen. This occurs consistently, making the Unity view unusable in the Flutter app.

Steps to Reproduce Set up the Unity project to export for Android (import fuw-2022.2.0.unitypackage as a custom asset add cube into the scene and attached the rotate.cs script located in /Assets/FlutterUnityIntegration/Demo/Rotate.cs, create a material (set a random color) and attache the material to the cube) and then follow the build settings steps. Configure the Flutter app to use the flutter-unity-view-widget. Load the Unity scene using the following widget configuration in Flutter:

UnityWidget(
    placeholder: Container(
        decoration: BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
                colors: <Color>[
                    Colors.blue,
                    Colors.blueAccent,
                    Colors.lightBlue,
                ],
            ),
        ),
        child: const Center(
            child: CircularProgressIndicator(
                color: Colors.white,
            )),
    ),
    onUnityCreated: onUnityCreated,
    fullscreen: false,
    useAndroidViewSurface: true,
    borderRadius: BorderRadius.zero,
),

Observe that the Unity scene appears briefly before turning white. Expected Behavior The Unity scene should remain visible and interactable within the Flutter app.

Actual Behavior The Unity scene loads for a second and then is replaced by a white screen.

Environment Unity Version: 2022.3.23f1 Flutter Version: Flutter (Channel stable, 3.19.6, on macOS 14.3.1 23D60 darwin-x64, locale en-MA) Device Information: Sunmi V2 (only android device available for testing) OS: Android 7.1.1

choji-160 commented 2 months ago

just had to rebuild the app