「XMLファイルの読み込み」の編集履歴(バックアップ)一覧はこちら
「XMLファイルの読み込み」(2015/04/05 (日) 17:48:13) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
using UnityEngine;
using System.Collections;
using System.Text;
using System.Xml;
using System.IO;
public class TMXLoader {
public void Load(string fLevel) {
TextAsset tmx = Resources.Load (fLevel) as TextAsset;
// XML解析開始
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml (tmx.text);
XmlNodeList mapList = xmlDoc.GetElementsByTagName("map");
foreach(XmlNode map in mapList) {
XmlNodeList childList = map.ChildNodes;
foreach(XmlNode child in childList) {
// 属性を取得
XmlAttributeCollection attrs = child.Attributes;
int w = int.Parse(attrs.GetNamedItem("width").Value); // 幅を取得.
int h = int.Parse(attrs.GetNamedItem("height").Value); // 高さを取得.