Skip to content

Commit 37c45a8

Browse files
committed
docs: Updated serialization documentation
1 parent 5bddba5 commit 37c45a8

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

docs/_docs/advanced-topics/custom-serialization.md

+32-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,45 @@ permalink: /wiki/custom-serialization/
44
---
55

66
When using RPC's, NetworkedVar's or any other MLAPI related task that requires serialization. The MLAPI uses a default serialization pipeline that looks like this:
7+
78
``
89
Custom Types => Built In Types => IBitWritable
910
``
1011

1112
That is, when the MLAPI first gets hold of a type, it will check for any custom types that the user have registered for serialization, after that it will check if it's a built in type, such as a Vector3, float etc. These are handled by default. If not, it will check if the type inherits IBitWritable, if it does, it will call it's write methods.
1213

14+
The builtin types that are handled by default are:
15+
16+
* Nullable types where the underlying type is supported
17+
* An array where the element type is supported (can be multi dimensional as this is done recursivley)
18+
* Byte
19+
* SByte
20+
* UInt16
21+
* Int16
22+
* UInt32
23+
* Int32
24+
* UInt64
25+
* Int64
26+
* Single
27+
* Double
28+
* String
29+
* Bool
30+
* Vector2
31+
* Vector3
32+
* Vector4
33+
* Color
34+
* Color32
35+
* Ray
36+
* Quaternion
37+
* Char
38+
* Enums
39+
* GameObject (Only if the GameObject has a NetworkedObject component that is spawned)
40+
* NetworkedObject (Only if spawned)
41+
* NetworkedBehaviour (Only if spawned)
42+
1343
With this flow, you can override **ALL** serialization for **ALL** types, even built in types, and with the API provided, it can even be done with types that you have not defined yourself, those who are behind a 3rd party wall, such as .NET types.
1444

15-
To do this, register a handler pair:
45+
To register a custom type, or override an already handeld type you need to register a handler pair.
1646

1747
```csharp
1848
// Tells the MLAPI how to serialize and deserialize Url in the future.
@@ -36,7 +66,7 @@ SerializationManager.RegisterSerializationHandlers<Url>((Stream stream, Url inst
3666
Everytime you call the Register method, you are overriding any previous serialization method previously defined by you, or the MLAPI library. This is the most respected serialization method.
3767

3868

39-
If you manually want to restore privilages to how they were previously for a type, you can use:
69+
You can also restore privilages to how they were previously for a type.
4070
```csharp
4171
// Removes the handlers for the type Url.
4272
SerializationManager.RemoveSerializationHandlers<Url>();

0 commit comments

Comments
 (0)