- 最后登录
- 2018-12-7
- 注册时间
- 2012-9-13
- 阅读权限
- 50
- 积分
- 1106
- 纳金币
- 85
- 精华
- 1
|
首先新建一个OpenURL.as的文件,程序如下:package {import flash.net.navigateToURL;import flash.net.URLRequest;/** * ... * @author ... */public class OpenURL{public static function OpenURLFlash(link:String):void{var request:URLRequest = new URLRequest(link);navigateToURL(request, '_blank');}}}好,接下来我们把这个文件导入unity新建的ActionScript的文件夹下,然后我们新建一个 OpenURL.cs的文件,程序如下:using UnityEngine;using System.Collections;[NotConverted][NotRenamed]public class OpenURL {public static void OpenURLFlash(string link){Debug.Log("this won't work until exported to a SWF");}}把该CS文件放在Plugins文件夹下,然后我们再编写一个测试文件Test.cs,程序如下:using UnityEngine;using System.Collections;using UnityEngine.Flash;public class Test : MonoBehaviour {private string url = "http://202.193.66.201/web/index.html";// Use this for initializationvoid Start () {ActionScript.Import("OpenURL");}// Update is called once per framevoid Update () {}void OnGUI(){if(GUI.Button(new Rect(10,10,200,50),"OpenWindow")){OpenURL.OpenURLFlash(url);}}}把我们的Test文件拖放到camera长,发布运行,下面是运行效果:
|
|