• Unity3d Resources TextAsset 文本


    一些小型数据,可以用txt文本作为媒介,进行获取、传输、修改、存储;

    比如:User1.2.3.txt,放入 Resources/Data 文件下;

    一,Unity3d Resources.Load 加载获取数据。

       TextAsset TXTFile = (TextAsset)Resources.Load("Data/board" + boardN.ToString() + "." + rows.ToString() + "." + columns.ToString());

      TextAsset TXTFile = (TextAsset)Resources.Load(STR_DataBoard + boardN.ToString() + "." + rows.ToString() + "." + columns.ToString());

          if (TXTFile != null)

         Debog.Log(TXTFile.text);   

            

    二,存储数据:

        // 存储路径

         string p = Application.dataPath +"/Resources/Data";

        TextWriter tw = new StreamWriter(Path.Combine(p, "board" + 1.ToString() + "." + 2.ToString() + "." + 3.ToString() +“.txt”), false, Encoding.ASCII);

    // f 为 数据

    string  f="ffffffff";

             tw.Write(f);

                tw.Flush();

                tw.Close();

    // 资源数据库.刷新   

     AssetDatabase.Refresh();

       

             

               

  • 相关阅读:
    xml
    反射
    类加载器
    TCP通信
    UDP通信
    网络通信
    【SpringBoot】Freemarkerの主キー
    【SpringBoot】Warの作成
    【Excel】ファイルの拡張子
    【SAP】TCODE表
  • 原文地址:https://www.cnblogs.com/kuangwu/p/3275083.html
Copyright © 2020-2023  润新知