mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-25 03:04:29 -05:00
- Server can host to clients - Players spawn in with a base character controller - Movement is synced between the two game clients
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
|
|
using MLAPI;
|
|
using UnityEngine;
|
|
|
|
namespace HelloWorld
|
|
{
|
|
public class HelloWorldManager : MonoBehaviour
|
|
{
|
|
void OnGUI()
|
|
{
|
|
GUILayout.BeginArea(new Rect(10, 10, 300, 300));
|
|
if (!NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)
|
|
{
|
|
StartButtons();
|
|
}
|
|
else
|
|
{
|
|
StatusLabels();
|
|
}
|
|
|
|
GUILayout.EndArea();
|
|
}
|
|
|
|
static void StartButtons()
|
|
{
|
|
if (GUILayout.Button("Host")) NetworkManager.Singleton.StartHost();
|
|
if (GUILayout.Button("Client")) NetworkManager.Singleton.StartClient();
|
|
if (GUILayout.Button("Server")) NetworkManager.Singleton.StartServer();
|
|
}
|
|
|
|
static void StatusLabels()
|
|
{
|
|
var mode = NetworkManager.Singleton.IsHost ?
|
|
"Host" : NetworkManager.Singleton.IsServer ? "Server" : "Client";
|
|
|
|
GUILayout.Label("Transport: " +
|
|
NetworkManager.Singleton.NetworkConfig.NetworkTransport.GetType().Name);
|
|
GUILayout.Label("Mode: " + mode);
|
|
}
|
|
}
|
|
} |