NEIL的Unity學習筆記(5) - XML 寫入 和 二三事
XML 寫入 和 二三事 應朋友要求幫忙寫了一個記帳用的手機程式,慣例順道來分享箇中經驗。 XML mini Accounting https://play.google.com/store/apps/details?id=com.CF.XmlminiAccount 首先非常感謝雨松 MOMO 的文章 http://www.xuanyusong.com/archives/1901 基本上我是以另一種方式再解釋一次 首先 了解一下檔案放置的位置 public static string filepath = Application.dataPath + @"/StreamingAssets/my.xml"; public static string filepath = Application.persistentDataPath+ "/my.xml" ; // for android 要讓手機裝置可以找到被 unity 所建立的檔案,必需要設定 file> build setting>player setting>other settings>configuration> write Access 設定為 external(SD card), 那檔案可以使用你手機的檔案管理員於 "Android/data/app/com.yourappname/files" 中找到 接下來開始說明如何建立 XML 檔案 首先載入要使用的資料庫 using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Xml; using System.IO; using System.Text; ------------------------------------------------------------------------ // 定義 xmlDoc 為 XmlDocument() 設定的屬性 ( 就是 xml). ...