//리스트에 저장되어있는 ItemID로 저장 public void SaveHaveItemID() { XmlWriter xmlWriter; //파일경로 string filePath = Application.persistentDataPath + "/Myitem.xml"; try { XmlWriterSettings xmlSetting = new XmlWriterSettings(); xmlSetting.Indent = true; xmlSetting.Encoding = Encoding.UTF8; xmlWriter = XmlWriter.Create( filePath, xmlSetting ); } catch (Exception e) { print(e.Message); return; } xmlWriter.WriteStartElement("MyItem"); int childItemBarCount = this.m_grid.transform.childCount; for (int i = 0; i < childItemBarCount; i++) { //작은 번호가 하이어라키 Transform childTrans = this.m_grid.transform.GetChild(i); ItemScript itemBar = childTrans.gameObject.GetComponent <ItemScript>(); if (itemBar != null) { int itemId = itemBar.GetInfo().Id; string strItemName = itemBar.GetInfo().Name; string strIcon = itemBar.GetInfo().Icon; string strHaveItem = itemBar.GetInfo().HaveItem; string strNextSaveItem = itemBar.GetInfo().NextSaveItem; string strObjectState = itemBar.GetInfo().ObjectState; string strEventItem = itemBar.GetInfo().EventItem; string strRelationObject = itemBar.GetInfo().RelationObject; string strLocking = itemBar.GetInfo().Locking; xmlWriter.WriteStartElement("Field"); xmlWriter.WriteAttributeString("id", itemId.ToString()); xmlWriter.WriteAttributeString("Name", strItemName.ToString()); xmlWriter.WriteAttributeString("Icon", strIcon.ToString()); xmlWriter.WriteAttributeString("HaveItem", strHaveItem.ToString()); xmlWriter.WriteAttributeString("NextSaveItem", strNextSaveItem.ToString()); xmlWriter.WriteAttributeString("ObjectState", strObjectState.ToString()); xmlWriter.WriteAttributeString("EventItem", strEventItem.ToString()); xmlWriter.WriteAttributeString("RelationObject", strRelationObject.ToString()); xmlWriter.WriteAttributeString("Locking", strLocking.ToString()); xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); xmlWriter.Close(); }