편집 기록

편집 기록
  • 프로필 알 수 없는 사용자님의 편집
    날짜2016.02.16

    유니티에서 XML파싱을 위해 WWW 클래스로 .XML 파일을 불러왔습니다. 불러들인 정보를 디시리얼라이즈하는 기능은 없나요?(안드로이드폰을 위해 개발중입니다.)


     IEnumerator read()
    
        {
            Text txt = GameObject.Find("ERRORMESSAGE2").GetComponent<Text>();
    
            string fileName = "Quests.xml";
            string filePath = "jar:file://" + Application.dataPath + "!/assets/" + fileName;
    
            var www = new WWW(filePath);
            yield return www;
            if (!string.IsNullOrEmpty(www.error))
            {
                txt.text = "로딩실패";
            }
            else if (string.IsNullOrEmpty(www.error))
            {
                txt.text = "로딩성공";
            }
        }
    

    불러들였습니다만 아래 iostream같이 디시리얼라이즈 하는 기능은 없나요?

     void serialize()
    
    {
    
    Type[ ] questType = { typeof(QUEST) };
    
            XmlSerializer serializer = new XmlSerializer(typeof(QuestContainer), questType);
    
            TextReader textReader = new StreamReader(filePath);
            QuestContainer = (QuestContainer)serializer.Deserialize(textReader);
            textReader.Close();
            txt.text = (textReader.ReadLine());
        }
    

    불러들인 정보를 아래 양식에 맞게 디시리얼라이즈하는 기능이 필요합니다..

    정보는 불러들여진 후 각 프로쎄스로 나눠져 컨테이너로 들어가게됩니다..

    public class QuestContainer
    {
    
        private List<QUEST> confirmed = new List<QUEST>();
        private List<QUEST> complete = new List<QUEST>();
        private List<QUEST> possible = new List<QUEST>();
        private List<QUEST> im_possible = new List<QUEST>();
    
        public List<QUEST> Confirmed
        {
            get { return confirmed; }
            set { confirmed = value; }
        }
    
        public List<QUEST> Complete
        {
            get { return complete; }
            set { complete = value; }
        }
    
        public List<QUEST> Possible
        {
            get { return possible; }
            set { possible = value; }
        }
    
        public List<QUEST> im_Possible
        {
            get { return im_possible; }
            set { im_possible = value; }
        }
    }
    
    public class QUEST
    {
        public string Questname { get; set; }
        public string Description { get; set; }
        public string Class { get; set; }
        public int Level { get; set; }
        public int STR { get; set; }
        public int CON { get; set; }
        public int INT { get; set; }
        public int WIS { get; set; }
        public int DEX { get; set; }
        public string Title { get; set; }
        public string Item { get; set; }
        public QUEST_TYPE questType { get; set; }
        public DIFFICULTY difficulty { get; set; }
        public EXPEDIENT eXPEDIENT { get; set; }
        public QUEST_REWARD questReward { get; set; }
        public string target { get; set; }
        public int count { get; set; }
        public bool canClear { get; set; }
    
        public QUEST()
        {
    
        }
    
        public QUEST(string Questname,string Description,string Class,int level,int str,int con, int Int, int wis, int dex,string title,string item,  QUEST_TYPE QuestType, DIFFICULTY Difficulty, QUEST_REWARD quest_reward, EXPEDIENT EXPEDIENT, string Target, int Count, bool canclear)
        {
            this.Description = Description;
            this.Questname = Questname;
            this.questType = QuestType;
            this.difficulty = Difficulty;
            this.eXPEDIENT = EXPEDIENT;
            this.questReward = quest_reward;
            this.Class = Class;
            this.Level = level;
            this.STR = str;
            this.CON = con;
            this.INT = Int;
            this.WIS = wis;
            this.DEX = dex;
            this.Title = title;
            this.Item = item;
            this.target = Target;
            this.count = Count;
            this.canClear = canclear;
        }
    
    <?xml version="1.0" encoding="utf-8"?>
    <QuestContainer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Confirmed>
        <QUEST>
          <Questname>시작</Questname>
          <Description>이제 시작이에요!</Description>
          <Class>ALL</Class>
          <Level>0</Level>
          <STR>0</STR>
          <CON>0</CON>
          <INT>0</INT>
          <WIS>0</WIS>
          <DEX>0</DEX>
          <Title />
          <Item />
          <questType>ROOP</questType>
          <difficulty>EASY</difficulty>
          <eXPEDIENT>MOVE</eXPEDIENT>
          <questReward>GOLD</questReward>
          <target>Bank</target>
          <count>10</count>
          <canClear>false</canClear>
        </QUEST>
      </Confirmed>
      <Complete />
      <Possible />
      <im_Possible />
    </QuestContainer>
    

    그런 기능이 없다면 수작업으로 주입하는 방법이라도 알려주시면 좋겠습니다.

    추가사항 -

    alt text

  • 프로필 정토드님의 편집
    날짜2016.02.15

    유니티에서 XML파싱을 위해 WWW 클래스로 .XML 파일을 불러왔습니다. 불러들인 정보를 디시리얼라이즈하는 기능은 없나요?(안드로이드폰을 위해 개발중입니다.)


     IEnumerator read()
    
        {
            Text txt = GameObject.Find("ERRORMESSAGE2").GetComponent<Text>();
    
            string fileName = "Quests.xml";
            string filePath = "jar:file://" + Application.dataPath + "!/assets/" + fileName;
    
            var www = new WWW(filePath);
            yield return www;
            if (!string.IsNullOrEmpty(www.error))
            {
                txt.text = "로딩실패";
            }
            else if (string.IsNullOrEmpty(www.error))
            {
                txt.text = "로딩성공";
            }
        }
    

    불러들였습니다만 아래 iostream같이 디시리얼라이즈 하는 기능은 없나요?

     void serialize()
    
    {
    
    Type[ ] questType = { typeof(QUEST) };
    
            XmlSerializer serializer = new XmlSerializer(typeof(QuestContainer), questType);
    
            TextReader textReader = new StreamReader(filePath);
            QuestContainer = (QuestContainer)serializer.Deserialize(textReader);
            textReader.Close();
            txt.text = (textReader.ReadLine());
        }
    

    alt text 불러들인 정보를 아래 양식에 맞게 디시리얼라이즈하는 기능이 필요합니다..

    정보는 불러들여진 후 각 프로쎄스로 나눠져 컨테이너로 들어가게됩니다..

    public class QuestContainer
    {
    
        private List<QUEST> confirmed = new List<QUEST>();
        private List<QUEST> complete = new List<QUEST>();
        private List<QUEST> possible = new List<QUEST>();
        private List<QUEST> im_possible = new List<QUEST>();
    
        public List<QUEST> Confirmed
        {
            get { return confirmed; }
            set { confirmed = value; }
        }
    
        public List<QUEST> Complete
        {
            get { return complete; }
            set { complete = value; }
        }
    
        public List<QUEST> Possible
        {
            get { return possible; }
            set { possible = value; }
        }
    
        public List<QUEST> im_Possible
        {
            get { return im_possible; }
            set { im_possible = value; }
        }
    }
    

    그런 기능이 없다면 수작업으로 주입하는 방법이라도 알려주시면 좋겠습니다.