diff --git a/Plugins/Android/libTLabWebView-release.aar b/Plugins/Android/libTLabWebView-release.aar index 0d51ef9..2fbc006 100644 Binary files a/Plugins/Android/libTLabWebView-release.aar and b/Plugins/Android/libTLabWebView-release.aar differ diff --git a/README-ja.md b/README-ja.md index 1f620ef..c9c6c35 100644 --- a/README-ja.md +++ b/README-ja.md @@ -198,6 +198,14 @@ android.useAndroidX=true > > ``` +> [!NOTE] +> WebViewで実装されているjavascriptインターフェース`window.tlab`は現在GeckoViewではサポートされていません.これはGeckoViewとjavaネイティブプラグイン(`.aar`)間の通信処理の実装の複雑さに起因します.現状は`window.tlab.unitySendMessage`の代替として`window.postMessage`の呼び出しでC#コンポーネントにメッセージを送信する機能のみ実装されていますが,将来的には`window.tlab`の機能をGeckoViewでも完全にサポートする計画です. +> GeckoViewのページスクリプトからC#コンポーネントにメッセージを送信する際は,以下のようにjavascriptを記述してください. +> ```.js +> let payload = { go: "Test", method: "OnMessage", message: "this is test message." }; +> window.postMessage({ type: "TLABWEBVIWE_GECKO_NATIVE_MESSAGE", payload: { method: "unitySendMessage", payload: payload } }, "*"); +> ``` + > [!WARNING] > このプラグインはAndroidデバイス上でのみ動作します.Unity Editor上で実行してもWebページは表示されないことに注意してください. diff --git a/README.md b/README.md index 8083b88..d99fe40 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,14 @@ By default, a virtual keyboard based on uGUI is available in this package. Howev > > ``` +> [!NOTE] +> The JavaScript interface `window.tlab`, which is implemented in WebView, is currently not supported in GeckoView. This is due to the complexity of implementing the communication process between GeckoView and the Java native plugin (`.aar`). Currently, only the functionality to send messages to C# components by calling `window.postMessage` as an alternative to `window.tlab.unitySendMessage` is implemented. However, there are plans to fully support the features of `window.tlab` in GeckoView in the future. +> When sending a message from a GeckoView page script to a C# component, use the following JavaScript: +> ```.js +> let payload = { go: "Test", method: "OnMessage", message: "this is test message." }; +> window.postMessage({ type: "TLABWEBVIWE_GECKO_NATIVE_MESSAGE", payload: { method: "unitySendMessage", payload: payload } }, "*"); +> ``` + > [!WARNING] > Note that this plugin only works on Android devices; it will not display web pages when run on the Unity Editor. diff --git a/Runtime/Test/OnMessageTest.cs b/Runtime/Test/OnMessageTest.cs new file mode 100644 index 0000000..c98db07 --- /dev/null +++ b/Runtime/Test/OnMessageTest.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace TLab.WebView.Test +{ + public class OnMessageTest : MonoBehaviour + { + public void OnMessage(string message) + { + Debug.Log($"{nameof(OnMessage)}: {message}"); + } + } +} diff --git a/Runtime/Test/OnMessageTest.cs.meta b/Runtime/Test/OnMessageTest.cs.meta new file mode 100644 index 0000000..1fdd46c --- /dev/null +++ b/Runtime/Test/OnMessageTest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e72edfc24f54fd9418df66c9a2a7dfeb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Samples/Scenes/Mobile Sample.unity b/Samples/Scenes/Mobile Sample.unity index a8baf75..3f77858 100644 --- a/Samples/Scenes/Mobile Sample.unity +++ b/Samples/Scenes/Mobile Sample.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -632,7 +631,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!81 &732371175 AudioListener: @@ -806,7 +805,7 @@ BoxCollider: m_IsTrigger: 0 m_Enabled: 1 serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} + m_Size: {x: 2, y: 2, z: 2} m_Center: {x: 0, y: 0, z: 0} --- !u!23 &834640420 MeshRenderer: @@ -871,7 +870,7 @@ Transform: m_ConstrainProportionsScale: 1 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: -31.95, z: 0} --- !u!1 &1139930389 GameObject: @@ -965,7 +964,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1 &1164393660 GameObject: @@ -1212,7 +1211,7 @@ Transform: m_ConstrainProportionsScale: 1 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1702036735 GameObject: @@ -1261,7 +1260,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1702036739 MonoBehaviour: @@ -1390,13 +1389,30 @@ RectTransform: m_Children: - {fileID: 724718907} m_Father: {fileID: 0} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!1 &1785763432 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 4545616402205158730, guid: 4272bd6725bd64846b07be9b4d76ad90, type: 3} + m_PrefabInstance: {fileID: 3182255550230140163} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1785763435 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1785763432} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e72edfc24f54fd9418df66c9a2a7dfeb, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!850595691 &2037102535 LightingSettings: m_ObjectHideFlags: 0 @@ -2349,7 +2365,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3182255551955723219, guid: 4272bd6725bd64846b07be9b4d76ad90, type: 3} propertyPath: m_RootOrder - value: 4 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3182255551955723219, guid: 4272bd6725bd64846b07be9b4d76ad90, type: 3} propertyPath: m_LocalPosition.x diff --git a/package.json b/package.json index be5ece5..1d55301 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.tlabaltoh.webview", - "version": "1.0.6", + "version": "1.0.8", "displayName": "TLabWebView", "description": "Plug-in to use Android's web browser component (WebView / GeckoView) as uGUI (Texture2D)", "author": {