Unity3d webplayer获取url参数

                                      Unity3d webplayer获取url参数

 1.Unity中代码,在Start方法中调用了HTML的GetUrl方法!Application.ExternalCall( "SayHello", "The game says hello!" ); 

 1 void Start () {
 2     Application.ExternalCall( "GetUrl", "" );
 3 }
 4  
 5 void myFunc( string str )
 6 {
 7     GameObject obj = GameObject.Find("GUI Text");
 8     GUIText txt = obj.GetComponent( "GUIText" ) as GUIText;
 9     txt.text = str;
10 }

    2.HTML代码

1 u.initPlugin(jQuery("#unityPlayer")[0], "FTP.unity3d");
2      
3 });
4  
5 function GetUrl( arg )
6 {
7         var url=document.URL;
8         u.getUnity().SendMessage("GameLogic", "myFunc", url);
9 }

u.getUnity().SendMessge()给webplayer传递参数,执行u3d中的MyFunc方法!

原文地址:https://www.cnblogs.com/alongu3d/p/3406200.html