Native Android Views invisible in 5.6 beta 3

I have a plugin that needs to open a few simple views (webviews, etc.) and is calling native Android code to do this. This code worked as expected in betas 1 and 2, but upon installing beta 3, all of the views are now invisible. They are still there – if I click around the device, I can still interact with the views, but I can’t actually see them. It’s as if all of the views have a visibility of INVISIBLE, but if I call getVisibility() they report that they are visible. Did beta 3 override the view drawing to prevent any non-Unity views from being rendered? Am I missing something obvious?

final Activity activity = UnityPlayer.currentActivity;
activity.runOnUiThread(new Runnable() {public void run() {

    Button mNotificationButton = new Button(activity);
    mNotificationButton.setText("Test View");
    mNotificationButton.setTextSize(20);
    mNotificationButton.setBackgroundColor(Color.WHITE);
    mNotificationButton.setTextColor(Color.BLACK);
    mNotificationButton.setWidth(300);
    mNotificationButton.setY(200);
    mNotificationButton.setX(300);


    mNotificationButton.setVisibility(View.VISIBLE);
    mNotificationButton.setClickable(true);
    mNotificationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d("button test", " button clicked");
        }
    });

    FrameLayout layout = new FrameLayout(activity);
    activity.addContentView(layout,
            new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT));
    layout.setFocusable(true);
    layout.setFocusableInTouchMode(true);
    layout.addView(mNotificationButton, new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT
    ));
}});

Hi matthewdickinson,
Could you please file a bug report with a minimal reproduction case and reply in this thread with the case #?

Case #869506

1 Like

I got the same problem.

I discovered that the native view is behind the Unity view.
That’s why it’s invisible.
How to set the native Android view above the Unity view?

Hi,

Thanks for finding and reporting this! I can confirm this behaviour and I’m currently looking into the cause.

Thanks!

Works OK on Unity 5.5.1f :wink:

Hello,

I tracked down when and where this happened and talked to the developers who work in this area. The behaviour is “by design”, the recommended way to do this, when developing plugins, is to use a separate window. (Adding views to the unity layout is not recommended because it’s likely to break)

1 Like