Unity3d C#XmlSerializer在创建对象后面停顿

时间:2016-07-26 01:14:06

标签: c# unity3d xmlserializer

XmlSerializer中的Unity3d出现了一个奇怪的问题。 它只是停止执行随机函数:

代码:

public void ReadXml(XmlReader reader) {
  myClimate = (Climate)int.Parse(reader.GetAttribute ("Climate"));
  reader.ReadToFollowing ("fertilities");
  List<int> ferIDs = new List<int>();
  while (reader.Read ()) {
    if (reader.IsStartElement ("fertility")) {
      ferIDs.Add (int.Parse (reader.GetAttribute ("ID")));
    }
    if(reader.Name == "fertilities"){
      break;
    }
  }
  foreach (int item in ferIDs) {
    myFertilities.Add (World.current.getFertility(item)); 
  }
  myCities = new List<City> ();
  wilderniss = null;
  reader.ReadToFollowing ("Cities");

  if (reader.ReadToDescendant ("City")) {
    do {
      Debug.Log ("City"); 
      //works till here 
      Debug.Log ("WTF?"); 
      City c = new City (this.myTiles,this);

      //but its stops here
      Debug.Log ("oh? ");//does not get called
      this.wilderniss = c;//does not get called
      Debug.Log ("OHO? spagettio");// does not get called
      c.ReadXml (reader);//Gets called
      myCities.Add (c);//gets also called


    } while(reader.ReadToNextSibling ("City"));
  }
}

为什么有些功能会被调用而有些则没有? 这怎么可能发生,因为几乎相同的代码在我的Programm的其他类中工作得很好?

0 个答案:

没有答案