码迷,mamicode.com
首页 > 编程语言 > 详细

利用WWW类获取Text并且在unityUGUI的Text中显示

时间:2015-12-21 18:33:48      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

先创建一个txt的文本,另存为修改一下格式改成UEF—8的。然后放入服务器或者本地都行。然后进行读取。

上代码

using UnityEngine.UI;
using System.IO;
public class GetBundle : MonoBehaviour {
public Text mytext;
void Start () 
{
StartCoroutine(LoadText());
}

IEnumerator LoadText()
	{
		string path = "http://172.27.35.1/Others/mytext.txt";
		WWW asset = new WWW(path);
		yield return asset;
		AssetBundle bundle = asset.assetBundle;
		Debug.Log(bundle);
		TextAsset textasset  =  bundle.LoadAsset("mytext",typeof(TextAsset)) as      TextAsset;
		mytext.text = textasset.text;
		bundle.Unload(false);
		asset.Dispose();
	}

}

 我这个是直接把txt文本放到了AssetBundle包中。然后放到web服务器上 www获取的。然后就这样吧。比较简单毕竟我也是初学者。

利用WWW类获取Text并且在unityUGUI的Text中显示

标签:

原文地址:http://www.cnblogs.com/unitySPK/p/5064034.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!