You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internally, the MLAPI uses Streams for it's data. This gives a ton of flexibility for the end user. If the end user for example doesn't want to use Streams but rather just byte arrays at their own level. They can do so by wrapping their arrays in MemoryStreams which doesn't create any garbage.
6
+
Internally, the MLAPI uses Streams for it's data. This gives a ton of flexibility for the end user. If the end user for example doesn't want to use Streams but rather just byte arrays at their own level. They can do so by wrapping their arrays in MemoryStreams which don't create any garbage.
7
7
8
8
9
-
The MLAPI does have it's own prefered Stream that is used internally. It's called the BitStream.
9
+
The MLAPI does have its own prefered Stream that is used internally. It's called the BitStream.
10
10
11
11
## BitStream
12
12
The BitStream is a Stream implementation that functions in a similar way as the MemoryStream. The main difference is that the BitStream have methods for operating on the Bit level rather than the Byte level.
@@ -34,18 +34,18 @@ When using the "Packed" versions of a write or read, the output will be VarInted
34
34
When using the "Diff" versions of an array write or read, the output will be the diff between two arrays, allowing for delta encoding.
35
35
36
36
#### Unity Types
37
-
The BitWriter & BitReader supports many data types by default such as Vector3, Vector2, Ray, Quaternion and more.
37
+
The BitWriter & BitReader support many data types by default such as Vector3, Vector2, Ray, Quaternion and more.
38
38
39
39
#### BitWise Writing
40
-
If you for example have an enum with 5 values. All those values could be fit into 3 bits. With the BitWriter, this can be done like this:
40
+
If you for example have an enum with 5 values. All those values could fit into 3 bits. With the BitWriter, this can be done like this:
41
41
42
42
```csharp
43
43
writer.WriteBits((byte)MyEnum.MyEnumValue, 3);
44
44
MyEnumvalue= (Myenum)reader.ReadBits(3);
45
45
```
46
46
47
-
#### Performance concideration
48
-
When the stream is not aligned, (BitAligned == false, this occurs when writing bits that does fill the whole byte, or when writing bools as they are written as bits), performance is decreased for each write and read. This is only a big concern if you are about to write a large amount of data after not being aligned. To solve this, the BitWriter allows you to "WritePadBits" and the BitReader then lets you skip those bits with "SkipPadBits" to align the stream to the nearest byte.
47
+
#### Performance consideration
48
+
When the stream is not aligned, (BitAligned == false, this occurs when writing bits that do fill the whole byte, or when writing bools as they are written as bits), performance is decreased for each write and read. This is only a big concern if you are about to write a large amount of data after not being aligned. To solve this, the BitWriter allows you to "WritePadBits" and the BitReader then lets you skip those bits with "SkipPadBits" to align the stream to the nearest byte.
49
49
50
50
```csharp
51
51
writer.WriteBool(true); //Now the stream is no longer aligned. Every byte has to be offset by 1 bit.
Copy file name to clipboardExpand all lines: docs/_docs/core-components/networked-object.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,4 +7,4 @@ The NetworkedObject is a fairly simple component. It has no settings. It's a com
7
7
8
8
If you want to use NetworkedBehaviours. You need a NetworkedObject at the same GameObject or in a parent. Each NetworkedObject has a "netId", a networkId for the GameObject. This is used by many parts of the MLAPI. From the message targeting system to the object spawning.
9
9
10
-
The components presence should have no performance impact as it has to game loop.
10
+
The component's presence should have no performance impact as it has no game loop.
ulong?prefabHash=SpawnManager.GetPrefabHashFromGenerator("MyPrefabHashGenerator"); // The prefab hash. Use null to use the default player prefab
22
+
// The prefab hash. Use null to use the default player prefab
23
+
// If using this hash, replace "MyPrefabHashGenerator" with the name of a prefab added to the NetworkedPrefabs field of your NetworkingManager object in the scene
Copy file name to clipboardExpand all lines: docs/_docs/getting-started/installation.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,13 +10,13 @@ To get started with the MLAPI. You need to install the library. The easiest way
10
10

11
11
12
12
13
-
Once imported into the Unity Engine, you will be able to use the components that it offers. To get started, you need a GameObject with the NetworkingManager component. Once you have that, use the Initializing the library articles to continue.
13
+
Once imported into the Unity Engine, you will be able to use the components that it offers. To get started, you need a GameObject with the NetworkingManager component. Once you have that, use the [Library Initialization](/wiki/library-initialization/) article to continue.
14
14
15
15
16
16
### Files
17
17
The MLAPI comes with 3 main components
18
18
##### MLAPI.dll
19
-
This DLL's is the runtime portion. The actual library. This file is thus **required**. It comes in two variants. A "Lite" and a normal version. Most people will do fine with the full version. The Lite version has less features. At the time of writing the only difference is that it does not include encryption which adds better support on certain platforms. Note that the lite version might not be as stable as the full version and could contain additional bugs.
19
+
This DLL is the runtime portion. The actual library. This file is thus **required**. It comes in two variants. A "Lite" and a normal version. Most people will do fine with the full version. The Lite version has less features. At the time of writing the only difference is that it does not include encryption which adds better support on certain platforms. Note that the lite version might not be as stable as the full version and could contain additional bugs.
20
20
##### MLAPI-Editor.unitypackage
21
21
This unitypackage includes the source files for all the Editor scripts. The UnityPackage will automatically place these source files in the Editor folder to avoid it being included in a build. **This is required**.
Copy file name to clipboardExpand all lines: docs/_docs/getting-started/library-initialization.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Library Initialization
3
3
permalink: /wiki/library-initialization/
4
4
---
5
5
6
-
Initializing the MLAPI is fairly simple. You need a GameObject with the NetworkingManager component added to it. The NetworkingManager class has a static singleton reference to itself making it easy to access from anywhere. The first configuration you have to do is to set the Transport. You can read more about Transports on the "Custom Transports" page.
6
+
Initializing the MLAPI is fairly simple. You need a GameObject with the NetworkingManager component added to it. The NetworkingManager class has a static singleton reference to itself making it easy to access from anywhere. The first configuration you have to do is to set the Transport. You can read more about Transports on the [Custom Transports](/wiki/custom-transports/) page.
7
7
8
8
9
9
To initialize the library. You have three options.
0 commit comments