/// <summary> /// Writes the object. /// </summary> /// <param name="value">Value.</param> /// <param name="type">Type.</param> protected virtual void WriteObject(object value, Type type) { if (value is ISavable) { m_Writer.Write("{"); m_IsFirstProperty = true; ISavable savable = value as ISavable; savable.OnWrite(this); m_Writer.Write("}"); } else if (SaveGameTypeManager.HasType(type)) { m_Writer.Write("{"); m_IsFirstProperty = true; SaveGameType saveGameType = SaveGameTypeManager.GetType(type); saveGameType.Write(value, this); m_Writer.Write("}"); } #if !UNITY_WSA || !UNITY_WINRT else if (value is ISerializable) { SerializationInfo info = new SerializationInfo(type, new FormatterConverter()); ISerializable serializable = value as ISerializable; serializable.GetObjectData(info, new StreamingContext(StreamingContextStates.All)); WriteSerializationInfo(info); } #endif else { WriteSavableMembers(value, type); } }
/// <summary> /// Writes the object. /// </summary> /// <param name="value">Value.</param> /// <param name="type">Type.</param> protected virtual void WriteObject(object value, Type type) { if (value is ISavable) { ISavable savable = value as ISavable; savable.OnWrite(this); } else if (SaveGameTypeManager.HasType(type)) { m_Writer.BaseStream.WriteByte(BinaryFormatter.SaveGameTypeStart); long position = m_Writer.BaseStream.Position; m_Writer.Write(0L); SaveGameType saveGameType = SaveGameTypeManager.GetType(type); saveGameType.Write(value, this); long lastPosition = m_Writer.BaseStream.Position; m_Writer.BaseStream.Position = position; m_Writer.Write(lastPosition); m_Writer.BaseStream.Position = lastPosition; m_Writer.BaseStream.WriteByte(BinaryFormatter.SaveGameTypeEnd); } #if !UNITY_WSA || !UNITY_WINRT else if (value is ISerializable) { SerializationInfo info = new SerializationInfo(type, new FormatterConverter()); ISerializable serializable = value as ISerializable; serializable.GetObjectData(info, new StreamingContext(StreamingContextStates.All)); WriteSerializationInfo(info); } #endif else { WriteSavableMembers(value, type); } }