浏览代码

Merge pull request #2 from Unity-Technologies/feature/networkingmanager-hud

Add NetworkingManagerHUD
/main
GitHub 4 年前
当前提交
55e5f0a5
共有 6 个文件被更改,包括 65 次插入0 次删除
  1. 8
      Assets/Scripts.meta
  2. 8
      Assets/Scripts/Development.meta
  3. 38
      Assets/Scripts/Development/NetworkingManagerHUD.cs
  4. 11
      Assets/Scripts/Development/NetworkingManagerHUD.cs.meta

8
Assets/Scripts.meta


fileFormatVersion: 2
guid: 8e8389b584b3f314a916cbb2dcfe78a9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/Development.meta


fileFormatVersion: 2
guid: 815bb3e9674d0a4419862e600a4d9536
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

38
Assets/Scripts/Development/NetworkingManagerHUD.cs


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);
}
}

11
Assets/Scripts/Development/NetworkingManagerHUD.cs.meta


fileFormatVersion: 2
guid: e26f82009f8f36d45a99adae79eab7b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存