【Webview】unity-webview/UniWebView3
8879 단어 Unity
unity-webview
단순 디스플레이
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleWebView : MonoBehaviour {
private string url = "https://www.google.co.jp/";
WebViewObject webViewObject;
void Start () {
webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>();
webViewObject.Init((msg) => {
Debug.Log(msg);
});
webViewObject.LoadURL(url);
// 中央に配置
webViewObject.SetMargins(Screen.width / 4, Screen.height / 4, Screen.width / 4, Screen.height / 4);
webViewObject.SetVisibility(true);
}
}
로컬 파일 보이기
• HTML 등 필요한 파일을
Assets/StreamingAssets/
아래에 구성· 파일의 읽기를
webViewObject.LoadURL("file://${filePath}");
로 변경한다.string filePath = System.IO.Path.Combine(Application.persistentDataPath, "sample.html");
webViewObject.LoadURL("file://" + filePath.Replace(" ", "%20"));
참고 자료Unity에서 WebView의 unity-webview 열기
Unity 3D의gree webview에 로컬 HTML을 표시하고 JS에서 Unity 코드를 실행하고 파일 읽기와 쓰기
UniWebView3
https://www.assetstore.unity3d.com/jp/?stay#!/content/92605
http://docs.uniwebview.com/api/
단순 디스플레이
UniWebView.cs
를 빈 대상에 부속시키면 된다.로컬 파일 보이기
● 프레젠테이션의
LocalHTMLSceneManager.cs
에 모든 객체를 첨부합니다.• fileName에
Assets/StreamingAssets/
아래 구성의 파일 경로를 입력합니다.・ 임의의 시기에 두드린다
LoadFromFileメソッド
.LocalHTMLSceneManager.cs
using UnityEngine;
public class LocalHTMLSceneManager : MonoBehaviour {
public string fileName;
public string htmlText;
#if UNITY_IOS || UNITY_ANDROID || UNITY_WP8
public void LoadFromFile() {
var webView = CreateWebView();
webView.url = UniWebViewHelper.streamingAssetURLForPath(fileName);
webView.Load();
webView.Show();
}
public void LoadFromText() {
var webView = CreateWebView();
webView.LoadHTMLString(htmlText, null);
webView.Show();
}
UniWebView CreateWebView() {
var webViewGameObject = GameObject.Find("WebView");
if (webViewGameObject == null) {
webViewGameObject = new GameObject("WebView");
}
var webView = webViewGameObject.AddComponent<UniWebView>();
webView.toolBarShow = true;
return webView;
}
#else //End of #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8
void Start() {
Debug.LogWarning("UniWebView only works on iOS/Android/WP8. Please switch to these platforms in Build Settings.");
}
#endif
}
참고 자료UNITY의 WEBVIEW 정보(브라우저 내장)
Reference
이 문제에 관하여(【Webview】unity-webview/UniWebView3), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/mczkzk/items/0ed0665c7da3b550770e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)