第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

unity serializer.Deserialize(stream)

unity serializer.Deserialize(stream)

C#
慕的地6264312 2022-10-15 14:33:32
誰(shuí)能告訴我我做錯(cuò)了什么?當(dāng)我在編輯器中玩游戲時(shí),一切正常。當(dāng)我構(gòu)建游戲并在那里嘗試保存游戲作品時(shí),但在加載游戲數(shù)據(jù)時(shí)出現(xiàn)此錯(cuò)誤:ArgumentNullException: Value cannot be null. 我一直在尋找解決方案,但似乎找不到任何解決方案。public void SaveGame(){    checkGameData();    XmlSerializer serializer = new XmlSerializer(typeof(PoliceSave));    FileStream stream = new FileStream(Application.persistentDataPath + "/gameData.xml", FileMode.Create);    serializer.Serialize(stream, policeSave);    stream.Close();    policeSave.GameData.Clear();    policeSave.Characters.Clear();    policeSave.Vehicles.Clear();    vehicleDetails.passenger.characters.Clear();    Debug.Log("[Server] Your game has been saved.");}public void LoadGame(){    clearGameObjects();    XmlSerializer serializer = new XmlSerializer(typeof(PoliceSave));    FileStream stream = new FileStream(Application.persistentDataPath + "/gameData.xml", FileMode.Open);    //try    //{        policeSave = serializer.Deserialize(stream) as PoliceSave;    //}catch    //{        Debug.Log("[Server] Error while loading game data!");    //}    stream.Close();    loadGameObjects();    policeSave.GameData.Clear();    policeSave.Characters.Clear();    policeSave.Vehicles.Clear();    vehicleDetails.passenger.characters.Clear();    Debug.Log("[Server] Your game has been loaded.");}[System.Serializable]public class GameData{    [XmlAttribute("Funds")]    public int funds;    [XmlAttribute("MissionID")]    public int missionId;}[System.Serializable]public class Passenger{    [XmlAttribute("Name")]    public List<string> characters;}[System.Serializable]public class Vec2Position{    [XmlAttribute("x")]    public float x;    [XmlAttribute("y")]    public float y;}[System.Serializable]public class Rotation{    [XmlAttribute("z")]    public float z;}[System.Serializable]public class CharacterDetails{    [XmlAttribute("Name")]    public string characterName;    [XmlAttribute("IsCameraSubject")]    public bool isCameraSubject;    public Vec2Position Position;    public Rotation Rotation;}
查看完整描述

1 回答

?
繁星coding

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超4個(gè)贊

在您的 XML 中,“乘客”是小寫的。你的班級(jí)名稱是大寫的。將您的 XML 屬性更改為<Passenger Name=""/>


您還應(yīng)該將其作為數(shù)組/列表,如下所示:


<Passengers>

    <Passenger Name="Gary" Position="Driver" />

    <Passenger Name="Mary" Position="Front Passenger" />

    <Passenger Name="Jorgen" Position="Back Left Passenger" />

    <Passenger Name="Alien 1" Position="Gary's Stomach" />

</Passengers>

額外的

為角色和乘客提供一個(gè) ID,以便他們可以在保存文件中的任何上下文中被引用?!懊Q”是模棱兩可的。那是唯一標(biāo)識(shí)符嗎?是顯示它們時(shí)使用的字符串嗎?


<Characters>

    <Character Name="Chuck" ID="1" />

    ...

</Characters>


...


<Passengers>

    <Passenger ID="1" />

    ...

</Passengers>


查看完整回答
反對(duì) 回復(fù) 2022-10-15
  • 1 回答
  • 0 關(guān)注
  • 130 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)