参照リンクをみながら実行したんですが、アラート出ずわからない状況です。
このwebviewを利用した方でわかる方いらっしゃいますでしょうか?
html
1<!DOCTYPE html> 2<html> 3<head> 4 <title>webview</title> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />s 6</head> 7<body> 8 <form name="mainForm" action="./mypage.php" method="POST"> 9 <input id="name" type="text" name="name"> 10 <input id="pass" type="password" name="pass"> 11 <input id="login" type="submit" value="ログイン"> 12 </form> 13 <button id="test">テスト</button> 14 <script type="text/javascript"> 15 // Unity.call("load"); 16 Unity.appLogin = function(data) { 17 alert(data); 18 } 19</body> 20</html>
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class WebViewFCM : MonoBehaviour { 6 7 private string url = "デモ用のurl"; 8 WebViewObject webViewObject; 9 10 11 // Use this for initialization 12 void Start() 13 { 14 webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>(); 15 webViewObject.Init((msg) => { 16 if (msg == "clicked") 17 { 18 webViewObject.SetVisibility(false); 19 } 20 }); 21 22 webViewObject.LoadURL(url); 23 webViewObject.SetMargins(50, 100, 50, 50); 24 webViewObject.SetVisibility(true); 25 26 // iOSのみUnity側でUnity.callを定義 実行はweb側で行う 27 if (Application.platform != RuntimePlatform.Android) 28 { 29 webViewObject.EvaluateJS( 30 "window.addEventListener('load', function() {" + 31 " window.Unity = {" + 32 " call:function(msg) {" + 33 " var iframe = document.createElement('IFRAME');" + 34 " iframe.setAttribute('src', 'unity:' + msg);" + 35 " document.documentElement.appendChild(iframe);" + 36 " iframe.parentNode.removeChild(iframe);" + 37 " iframe = null;" + 38 " }" + 39 " }" + 40 "}, false);"); 41 } 42 43 webViewObject.EvaluateJS("Unity.appLogin('test');"); 44 45 } 46 47 // Update is called once per frame 48 void Update() 49 { 50 51 } 52} 53
あなたの回答
tips
プレビュー