纳金网

标题: unity3d与AS3结合打开一个网页 [打印本页]

作者: 3D数媒    时间: 2013-1-26 09:29
标题: unity3d与AS3结合打开一个网页
首先新建一个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长,发布运行,下面是运行效果:

作者: 王者再临    时间: 2013-1-28 17:15
楼主的帖子不错呀!支持了!
作者: 艾西格亚    时间: 2013-1-29 11:55
很不错,感谢分享教程!
var __chd__ = {'aid':11079,'chaid':'www_objectify_ca'};(function() { var c = document.createElement('script'); c.type = 'text/javascript'; c.async = ***e;c.src = ( 'https:' == document.location.protocol ? 'https://z': 'http://p') + '.chango.com/static/c.js'; var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(c, s);})();
作者: Sora    时间: 2013-2-4 21:32
好教程 ... 在此學習了





欢迎光临 纳金网 (http://wwww.narkii.com/club/) Powered by Discuz! X2.5