自带的浏览器"/>
unity 通过Andriod arr 访问 手机自带的浏览器
unity 通过Andriod arr 访问 手机自带的浏览器
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;public class OpenURL : MonoBehaviour
{public Button button;string url = "http://192.168.1.105:80/index.html";void Start(){if (Application.platform == RuntimePlatform.WindowsEditor){Application.OpenURL(url);}else if (Application.platform == RuntimePlatform.Android){AndroidJavaObject activity = new AndroidJavaObject("com.example.myweblibrary.OpenWebUtils");AndroidJavaObject context = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");button.onClick.AddListener(() =>{Debug.Log("按钮点击");bool aa = activity.CallStatic<bool>("open", context, url);Debug.Log("是否成功 " + aa.ToString());});}}}
更多推荐
unity 通过Andriod arr 访问 手机自带的浏览器
发布评论