Skip to content

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

@choji-160

Description

@choji-160

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions