The Unity MLAPI (Mid level API) is a framework that simplifies building networked games in Unity. It offers low level access to core networking while at the same time providing high level abstractions. The MLAPI aims to remove the repetetive tasks and reduces the network code dramatically, no matter how many of the modular features you use.
To get started, check the Wiki. This is also where most documentation lies. Follow the quickstart, join our Discord and get started today!
For general questions, networking advice or discussions about MLAPI, please join our Discord Community or create a post in the Unity Multiplayer Forum.
The MLAPI supports all major Unity platforms. To use the WebGL platform a custom WebGL transport based on web sockets is needed.
MLAPI is compatible with Unity 2019 and newer versions.
We follow the Gitflow Workflow. The master branch contains our latest stable release version while the develop branch tracks our current work.
The MLAPI is an open-source project and we encourage and welcome contributions. If you wish to contribute, be sure to review our contribution guidelines
If you have an issue, bug or feature request, please follow the information in our contribution guidelines to submit an issue.
Here is a sample MonoBehaviour showing a chat script where everyone can write and read from. This shows the basis of the MLAPI and the abstractions it adds.
public class Chat : NetworkedBehaviour
{
private NetworkedList<string> ChatMessages = new NetworkedList<string>(new MLAPI.NetworkedVar.NetworkedVarSettings()
{
ReadPermission = MLAPI.NetworkedVar.NetworkedVarPermission.Everyone,
WritePermission = MLAPI.NetworkedVar.NetworkedVarPermission.Everyone,
SendTickrate = 5
}, new List<string>());
private string textField = "";
private void OnGUI()
{
if (IsClient)
{
textField = GUILayout.TextField(textField, GUILayout.Width(200));
if (GUILayout.Button("Send") && !string.IsNullOrWhiteSpace(textField))
{
ChatMessages.Add(textField);
textField = "";
}
for (int i = ChatMessages.Count - 1; i >= 0; i--)
{
GUILayout.Label(ChatMessages[i]);
}
}
}
}