Skip to content

Commit da6f94b

Browse files
author
Oskari Leppäaho
committed
Fix invisible native input field on Unity 5.6
In 5.6 Unity changed their own view to be the topmost one in the Activity so all the plugins that add stuff to the same activity will be drawn below all Unity stuff. Override that behaviour by extending the UnityPlayer. Some discussion here: https://forum.unity3d.com/threads/android-input-in-fragment-invisible-but-still-interactable-after-update-to-unity-5-6-1.471426/.
1 parent 265bded commit da6f94b

4 files changed

Lines changed: 46 additions & 2 deletions

File tree

demo/Assets/Plugins/Android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
android:icon="@drawable/app_icon"
1818
android:label="@string/app_name"
1919
android:debuggable="true">
20-
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
20+
<activity android:name="com.bkmin.android.UnityPlayerNotOnTopActivity"
2121
android:label="@string/app_name">
2222
<intent-filter>
2323
<action android:name="android.intent.action.MAIN" />

release/NativeEditPlugin/Plugins/Android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
android:icon="@drawable/app_icon"
1818
android:label="@string/app_name"
1919
android:debuggable="true">
20-
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
20+
<activity android:name="com.bkmin.android.UnityPlayerNotOnTopActivity"
2121
android:label="@string/app_name">
2222
<intent-filter>
2323
<action android:name="android.intent.action.MAIN" />
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.bkmin.android;
2+
3+
import com.unity3d.player.*;
4+
import android.content.ContextWrapper;
5+
import android.view.SurfaceView;
6+
import android.view.View;
7+
import android.util.Log;
8+
9+
public class UnityPlayerNotOnTop
10+
extends UnityPlayer
11+
{
12+
public UnityPlayerNotOnTop(ContextWrapper contextwrapper)
13+
{
14+
super(contextwrapper);
15+
}
16+
17+
public void addView(View child)
18+
{
19+
if (child instanceof SurfaceView) {
20+
((SurfaceView)child).setZOrderOnTop(false);
21+
}
22+
super.addView(child);
23+
}
24+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.bkmin.android;
2+
3+
import com.unity3d.player.*;
4+
import android.os.Bundle;
5+
import android.util.Log;
6+
7+
public class UnityPlayerNotOnTopActivity
8+
extends UnityPlayerActivity
9+
{
10+
@Override
11+
public void onCreate(Bundle bundle)
12+
{
13+
requestWindowFeature(1);
14+
super.onCreate(bundle);
15+
getWindow().setFormat(2);
16+
mUnityPlayer = new UnityPlayerNotOnTop(this);
17+
setContentView(mUnityPlayer);
18+
mUnityPlayer.requestFocus();
19+
}
20+
}

0 commit comments

Comments
 (0)