</pre>AssetBundle 动态加载场景<p></p><p></p><pre name="code" class="csharp"> WWW download = WWW.LoadFromCacheOrDownload("file://E:/MirPenUU/sence_gamefarm.ab", 1);
<span style="white-space:pre"> </span> //两种方法都可以
<span style="white-space:pre"></span><pre name="code" class="csharp"><span style="white-space:pre"> </span> WWW download = new WWW(<span style="font-family: Arial, Helvetica, sans-serif;">"file://E:/MirPenUU/sence_gamefarm.ab"</span><span style="font-family: Arial, Helvetica, sans-serif;">);</span>
if (download.error != null) { Debug.LogError(download.error); } AssetBundle bundle = download.assetBundle; Application.LoadLevel("GameFarm1");
www上传文件
IEnumerator getTexture2d()
{
WWWForm form = new WWWForm();
form.AddField("gid", "456");
form.AddField("uid", "1");
form.AddField("type", UpStr);
form.AddBinaryData("file", m_Tex.EncodeToJPG()); //文件为二进制
wwwProcess = new WWW(Constant.UPDATE_URL, form);
yield return wwwProcess;
if (wwwProcess.error == null)
{
//成功
}
else
{
//失败
}
}
www 带参数网络请求
IEnumerator HTTPClient(string str)
{
Debug.Log("zdp HTTPClient :" + str);
WWWForm form = new WWWForm ();
form.AddField("id", Constant.uuid);
form.AddField("op", str);
WWW www = new WWW(Constant.CONTROL_URL, form);
yield return www;
if (www.error != null)
Debug.Log(" result Erro zdp:" + www.error);
else
{
fastHit(www.text);
}
}
网络请求显示滚动条
void Update()
{
if (this.www != null && progressSlider != null && !this.www.isDone)
{
this.progressSlider.value = this.www.progress;
}
}
www在不同平台路径的使用方法
#if UNITY_STANDALONE_WIN
filepath = "file://" + Application.dataPath + "/StreamingAssets/" + jsonName;
#endif
#if UNITY_ANDROID
filepath = Application.streamingAssetsPath + "/" + jsonName;
#endif
#if UNITY_IOS
filepath = Application.streamingAssetsPath + "/" + jsonName;
#endif