zoukankan      html  css  js  c++  java
  • 利用WWW类获取Text并且在unityUGUI的Text中显示

    先创建一个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获取的。然后就这样吧。比较简单毕竟我也是初学者。

  • 相关阅读:
    51Nod1119
    stoi
    坑爹大质数
    USACO07OPEN Cheapest Palindrome
    USACO08NOV Mixed Up Cows
    USACO12FEB Nearby Cows
    SCOI2009 粉刷匠
    USACO16OPEN 248
    POI2014 PTA-Little Bird
    USACO17FEB Why Did the Cow Cross the Road I G
  • 原文地址:https://www.cnblogs.com/unitySPK/p/5064034.html
Copyright © 2011-2022 走看看