Unity WebView

By admin , 22 五月, 2026
  1. 在Unity创建一个3D Core工程PicoWebShell
  2. 下载Unity WebView插件(它的sample工程好像不能正常运行):https://github.com/gree/unity-webview
  3. 双击导入dist/unity-webview.unitypackage
  4. 创建一个空对象
  5. 在Assets目录里创建下面WebShell.cs文件,然后拖到空对象
  6. 点播放即可
using UnityEngine;
using Gree.UnityWebView;


public class WebShell : MonoBehaviour
{
    private WebViewObject webView;


    void Start()
    {
        // 创建WebView
        webView = gameObject.AddComponent<WebViewObject>();

        // 初始化
        webView.Init((msg) =>
        {
            Debug.Log("Web消息: " + msg);
        });

        // 设置网页显示位置(全屏)
        webView.SetMargins(0, 0, 0, 0);

        // 启动网页
        webView.LoadURL("https://。。。");

        // 显示出来
        webView.SetVisibility(true);
        
        Debug.Log("✅ WebView 启动成功!");
    }
}

 

 

 

标签

评论

Restricted HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <img src>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。
CAPTCHA
请输入"Drupal"
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.