public override void OnSaveData() { try { Log.Info("OnSaveData() ...", true); var man = NetworkExtensionManager.Instance; Assertion.AssertNotNull(DataVersion, "DataVersion"); var s = SimpleDataSerializer.Writer(DataVersion, man.SerializationCapacity); man.Serialize(s); serializableDataManager.SaveData(DATA_ID, s.GetBytes()); Log.Info("OnSaveData() was successful!", true); } catch (Exception ex) { ex.Log(); } }
static void Test() { return; LogCalled(); byte[] data; { var man = NetworkExtensionManager.CreateNew(); man.LaneBuffer[1].m_flags = NetLaneExt.Flags.Custom0; Log.Debug("Serialize lane flags:" + man.LaneBuffer[1].m_flags); var s = SimpleDataSerializer.Writer(new Version(1, 1), 100); man.Serialize(s); data = s.GetBytes(); } { var man = NetworkExtensionManager.CreateNew(); Log.Debug("Before Deserialize lane flags :" + man.LaneBuffer[1].m_flags); var s = SimpleDataSerializer.Reader(data); man.DeserializeImp(s); Log.Debug("After Deserialize lane flags :" + man.LaneBuffer[1].m_flags); } }
static SimpleDataSerializer GetWriter() => SimpleDataSerializer.Writer(version, 100);