Data Serialization
Serialization and deserialization of data for the purpose of sending it across the network.
Last updated
Serialization and deserialization of data for the purpose of sending it across the network.
Last updated
Anytime you use a type within a Fish-Networking automatically recognizes you wish to send the type over the network, and will create a serializer for it. FishNet will only attempt to automatically serialize public fields and properties. You do not need to perform any extra steps for this process, but if you would like to exclude such fields from being serialized use [System.NonSerialized]
above the field.
For example, Name and Level will be sent over the network but not Victories.
Fish-Networking is also capable of serializing inherited values. In the type MonsterStat below, Health, Name, and Level will automatically serialize.
FishNet should be able to automatically serialize many basic C# and Unity types as well as classes and structs made with serializable types.
This attribute is part of the System
namespace, and may be used to prevent a field from being serialized over the network when using your own types. It's important to remember that placing NonSerialized over a field will also prevent it from showing in the inspector, nor working for other serializers such as JsonUtility.
In very rare cases a data type cannot be automatically serialized; a Sprite is a good example of this. It would be very difficult and expensive to serialize the actual image data and send that over the network. Instead, you could store your sprites in a collection and send the collection index, or perhaps you could create a .