Unity3d webplayer获取url参数
1.Unity中代码,在Start方法中调用了HTML的GetUrl方法!Application.ExternalCall( "SayHello", "The game says hello!" );
void Start () {
Application.ExternalCall( "GetUrl", "" );
} void myFunc( string str )
{
GameObject obj = GameObject.Find("GUI Text");
GUIText txt = obj.GetComponent( "GUIText" ) as GUIText;
txt.text = str;
}
2.HTML代码
u.initPlugin(jQuery("#unityPlayer")[], "FTP.unity3d"); }); function GetUrl( arg )
{
var url=document.URL;
u.getUnity().SendMessage("GameLogic", "myFunc", url);
}
u.getUnity().SendMessge()给webplayer传递参数,执行u3d中的MyFunc方法!