Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ rebuilt the apk. Although some old/buggy devices may not work well
with `android:hardwareAccelerated="true"`, the WebView runs very
smoothly with this setting.

For Unity 5.6 or newer, you also need to modify `android:name` from
`com.unity3d.player.UnityPlayerActivity` to
`net.gree.unitywebview.CUnityPlayerActivity`. This custom activity
implementation will adjust Unity's SurfaceView z order. Please refer
`plugins/Android/src/net/gree/unitywebview/CUnityPlayerActivity.java`
and `plugins/Android/src/net/gree/unitywebview/CUnityPlayer.java` if
you already have your own acitivity implementation.

### Web Player

The implementation utilizes IFRAME so please put both
Expand Down
Binary file modified dist/unity-webview.unitypackage
Binary file not shown.
Binary file modified dist/unity-webview.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions plugins/Android/Editor/UnityWebViewPostprocessBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ public static void OnPostprocessBuild(BuildTarget buildTarget, string path) {
doc.Save(manifest);
Debug.LogError("adjusted AndroidManifest.xml about android:hardwareAccelerated. Please rebuild the app.");
}
#if UNITY_5_6_OR_NEWER
if (activity != null
&& activity.GetAttribute("android:name") == "com.unity3d.player.UnityPlayerActivity") {
activity.SetAttribute("name", "http://schemas.android.com/apk/res/android", "net.gree.unitywebview.CUnityPlayerActivity");
doc.Save(manifest);
Debug.LogError("adjusted AndroidManifest.xml about android:name. Please rebuild the app.");
}
#endif
}
}

Expand Down
21 changes: 21 additions & 0 deletions plugins/Android/src/net/gree/unitywebview/CUnityPlayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.gree.unitywebview;

import com.unity3d.player.*;
import android.content.ContextWrapper;
import android.view.SurfaceView;
import android.view.View;

public class CUnityPlayer
extends UnityPlayer
{
public CUnityPlayer(ContextWrapper contextwrapper) {
super(contextwrapper);
}

public void addView(View child) {
if (child instanceof SurfaceView) {
((SurfaceView)child).setZOrderOnTop(false);
}
super.addView(child);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.gree.unitywebview;

import com.unity3d.player.*;
import android.os.Bundle;

public class CUnityPlayerActivity
extends UnityPlayerActivity
{
@Override
public void onCreate(Bundle bundle) {
requestWindowFeature(1);
super.onCreate(bundle);
getWindow().setFormat(2);
mUnityPlayer = new CUnityPlayer(this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
}
}