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
));
}});