Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

unityplayer.ForwardNativeEventsToDalvik=true for Android 2.3 or later

  • Loading branch information...
commit c049c334b8767fde5a71562700724b2e7e8273c3 1 parent b2566e7
@splhack splhack authored
View
42 plugins/Android/src/net/gree/unitywebview/WebViewPlugin.java
@@ -55,18 +55,15 @@ public void call(String message)
{
private static FrameLayout layout = null;
private WebView mWebView;
- private boolean mNeedsInput;
private long mDownTime;
public WebViewPlugin()
{
}
- public boolean Init(final String gameObject)
+ public void Init(final String gameObject)
{
final Activity a = UnityPlayer.currentActivity;
- mNeedsInput = a.getClass().getSimpleName().compareTo(
- "UnityPlayerNativeActivity") == 0;
a.runOnUiThread(new Runnable() {public void run() {
mWebView = new WebView(a);
@@ -97,8 +94,6 @@ public boolean Init(final String gameObject)
webSettings.setPluginsEnabled(true);
}});
-
- return mNeedsInput;
}
public void Destroy()
@@ -164,39 +159,4 @@ public void SetVisibility(final boolean visibility)
}});
}
-
- public void Update(final float x, final float y,
- final boolean down, final boolean press, final boolean release)
- {
- if (!mNeedsInput || mWebView == null)
- return;
-
- Activity a = UnityPlayer.currentActivity;
- a.runOnUiThread(new Runnable() {public void run() {
-
- long time = SystemClock.uptimeMillis();
- if (down)
- mDownTime = time;
-
- int action;
- if (press) {
- action = MotionEvent.ACTION_DOWN;
- } else if (release) {
- action = MotionEvent.ACTION_UP;
- } else {
- action = MotionEvent.ACTION_MOVE;
- }
-
- MotionEvent motionEvent = MotionEvent.obtain(
- mDownTime,
- time,
- action,
- x,
- y,
- 0);
-
- mWebView.dispatchTouchEvent(motionEvent);
-
- }});
- }
}
View
22 plugins/WebViewObject.cs
@@ -52,7 +52,6 @@ public class WebViewObject : MonoBehaviour
#elif UNITY_ANDROID
AndroidJavaObject webView;
Vector2 offset;
- bool needsInput;
#endif
#if UNITY_EDITOR || UNITY_STANDALONE_OSX
@@ -122,7 +121,7 @@ public void Init(Callback cb = null)
#elif UNITY_ANDROID
offset = new Vector2(0, 0);
webView = new AndroidJavaObject("net.gree.unitywebview.WebViewPlugin");
- needsInput = webView.Call<bool>("Init", name);
+ webView.Call("Init", name);
#endif
}
@@ -214,25 +213,6 @@ public void CallFromJS(string message)
callback(message);
}
-#if !UNITY_EDITOR && UNITY_ANDROID
- void Update()
- {
- if (!needsInput)
- return;
-
- bool down = Input.GetButton("Fire1");
- bool press = Input.GetButtonDown("Fire1");
- bool release = Input.GetButtonUp("Fire1");
-
- if (!down && !press && !release)
- return;
-
- Vector3 pos = Input.mousePosition;
- webView.Call("Update", pos.x - offset.x,
- Screen.height - (pos.y - offset.y), down, press, release);
- }
-#endif
-
#if UNITY_EDITOR || UNITY_STANDALONE_OSX
void OnGUI()
{
View
2  sample/.gitignore
@@ -1,3 +1,5 @@
Assets/Plugins
Assets/Plugins.meta
+!Assets/Plugins/Android/AndroidManifest.xml
+!Assets/Plugins/Android/AndroidManifest.xml.meta
Library
View
42 sample/Assets/Plugins/Android/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.unity3d.player"
+ android:installLocation="preferExternal"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <supports-screens
+ android:smallScreens="true"
+ android:normalScreens="true"
+ android:largeScreens="true"
+ android:xlargeScreens="true"
+ android:anyDensity="true"/>
+
+ <application
+ android:icon="@drawable/app_icon"
+ android:label="@string/app_name"
+ android:debuggable="true">
+ <activity android:name="com.unity3d.player.UnityPlayerProxyActivity"
+ android:label="@string/app_name"
+ android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity android:name="com.unity3d.player.UnityPlayerActivity"
+ android:label="@string/app_name"
+ android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
+ </activity>
+ <activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
+ android:label="@string/app_name"
+ android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
+ <meta-data android:name="android.app.lib_name" android:value="unity" />
+ <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
+ </activity>
+ <activity android:name="com.unity3d.player.VideoPlayer"
+ android:label="@string/app_name"
+ android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
+ </activity>
+ </application>
+</manifest>
View
2  sample/Assets/Plugins/Android/AndroidManifest.xml.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3924e2d1e0532405b9be3a09a0e9cbf7
Please sign in to comment.
Something went wrong with that request. Please try again.