您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
38 行
1.0 KiB
38 行
1.0 KiB
using UnityEngine;
|
|
using MLAPI;
|
|
|
|
[RequireComponent(typeof(NetworkingManager))]
|
|
public class NetworkingManagerHUD : MonoBehaviour
|
|
{
|
|
void OnGUI()
|
|
{
|
|
|
|
GUILayout.BeginArea(new Rect(10, 10, 300, 300));
|
|
if (!NetworkingManager.Singleton.IsClient && !NetworkingManager.Singleton.IsServer)
|
|
{
|
|
StartButtons();
|
|
}
|
|
else
|
|
{
|
|
StatusLabels();
|
|
}
|
|
|
|
GUILayout.EndArea();
|
|
}
|
|
|
|
void StartButtons()
|
|
{
|
|
if (GUILayout.Button("Host")) NetworkingManager.Singleton.StartHost();
|
|
if (GUILayout.Button("Client")) NetworkingManager.Singleton.StartClient();
|
|
if (GUILayout.Button("Server")) NetworkingManager.Singleton.StartServer();
|
|
}
|
|
|
|
void StatusLabels()
|
|
{
|
|
string mode = NetworkingManager.Singleton.IsHost ? "Host" : NetworkingManager.Singleton.IsServer ? "Server" : "Client";
|
|
|
|
GUILayout.Label("Transport: " + NetworkingManager.Singleton.NetworkConfig.NetworkTransport.GetType().Name);
|
|
GUILayout.Label("Mode: " + mode);
|
|
}
|
|
}
|
|
|