Страница:
Binary Serialization
Страницы
Attribute Message System
Binary Serialization
BitWriter & BitReader
Connection Approval
Core Components
Custom Transports
Dedicated Servers
Differences from UNET HLAPI
Getting Started
HLAPI Differences
Handshake
Home
Lag Compensation
Library Initialization
Limitations
Message Encryption
Message System
Modularity
NetworkConfig
NetworkProfiler Editor Window
Networked Object Pooling
NetworkedAnimator
NetworkedBehaviour
NetworkedNavMeshAgent
NetworkedObject
NetworkedTransform
NetworkedVar
NetworkingManager
Object & Behaviour Relation
Object Ownership
Object Spawning
Observer
Optimization
Passthrough Messages
Prototype Components
Roadmap
Scene Management
SyncedVars
Targeted Messages
TrackedObject
5
Binary Serialization
Albin Corén редактировал(а) эту страницу 2018-07-24 15:16:05 +02:00
Содержание
This documentation is outdated.
The MLAPI has a built-in binary serializer that serializes and supported fields in structs or classes. The serializer comes from this repository. However, as of v1.0.4 the Serializer uses the BitWriter internally thus supports all the types that the BitWriter supports.
Usage is simple.
byte[] binary = BinarySerializer.Serialize<MyClass>(myClass);
MyClass myClass = BinarySerializer.Deserialize<MyClass>(binary);
The supported data types and their sizes are listed below
Bool, Byte, Double, Single, Int, Long, SByte, Short, UInt, ULong, UShort, String, Vector3, Vector2, Quaternion, BoolArray, ByteArray, DoubleArray, SingleArray, IntArray, LongArray, SByteArray, ShortArray, UIntArray, ULongArray, UShortArray, StringArray, Vector3Array, Vector2Array, QuaternionArray
You can also do serialization as part of your message
//Sending
SendToServer<MyClass>("OnMyClass", "MyChannel", myClassInstance);
//Receiving
private void OnMyClass(uint clientId, byte[] data)
{
MyClass myClassInstance = DeserializeMessage(data);
//Do something with myClassInstance
}
Getting Started
The Basics
- Message System
- Object Spawning
- Object & Behaviour Relation
- Modularity
- NetworkedVar
- Scene Management
- Object Ownership
Components
Advanced Topics
- Encryption
- Networked Object Pooling
- Lag Compensation
- BitWriter & BitReader
- Custom Transports
- Optimization
- Network Profiler Window
- Dedicated Servers