mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Removed NetworkManagerPreview because it offer nothing of value and no one even knew that it existed
This commit is contained in:
parent
e8a5cfae65
commit
1e55a28f67
@ -59,7 +59,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="NetworkAnimatorEditor.cs" />
|
<Compile Include="NetworkAnimatorEditor.cs" />
|
||||||
<Compile Include="NetworkManagerEditor.cs" />
|
<Compile Include="NetworkManagerEditor.cs" />
|
||||||
<Compile Include="NetworkManagerPreview.cs" />
|
|
||||||
<Compile Include="NetworkTransformChildEditor.cs" />
|
<Compile Include="NetworkTransformChildEditor.cs" />
|
||||||
<Compile Include="NetworkTransformEditor.cs" />
|
<Compile Include="NetworkTransformEditor.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -1,106 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityObject = UnityEngine.Object;
|
|
||||||
|
|
||||||
namespace Mirror
|
|
||||||
{
|
|
||||||
[CustomPreview(typeof(NetworkManager))]
|
|
||||||
class NetworkManagerPreview : ObjectPreview
|
|
||||||
{
|
|
||||||
NetworkManager m_Manager;
|
|
||||||
GUIContent m_Title;
|
|
||||||
|
|
||||||
protected GUIContent m_ShowServerMessagesLabel;
|
|
||||||
protected GUIContent m_ShowClientMessagesLabel;
|
|
||||||
|
|
||||||
const int k_Padding = 4;
|
|
||||||
const int k_ColumnWidth = 120;
|
|
||||||
const int k_RowHeight = 16;
|
|
||||||
|
|
||||||
public override void Initialize(UnityObject[] targets)
|
|
||||||
{
|
|
||||||
base.Initialize(targets);
|
|
||||||
GetNetworkInformation(target as NetworkManager);
|
|
||||||
|
|
||||||
m_ShowServerMessagesLabel = new GUIContent("Server Message Handlers:", "Registered network message handler functions");
|
|
||||||
m_ShowClientMessagesLabel = new GUIContent("Client Message Handlers:", "Registered network message handler functions");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override GUIContent GetPreviewTitle()
|
|
||||||
{
|
|
||||||
m_Title = m_Title ?? new GUIContent("NetworkManager Message Handlers");
|
|
||||||
return m_Title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool HasPreviewGUI()
|
|
||||||
{
|
|
||||||
return m_Manager != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPreviewGUI(Rect r, GUIStyle background)
|
|
||||||
{
|
|
||||||
if (Event.current.type != EventType.Repaint)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_Manager == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int posY = (int)(r.yMin + k_Padding);
|
|
||||||
|
|
||||||
posY = ShowServerMessageHandlers(r, posY);
|
|
||||||
ShowClientMessageHandlers(r, posY);
|
|
||||||
}
|
|
||||||
|
|
||||||
static string FormatHandler(KeyValuePair<short, NetworkMessageDelegate> handler)
|
|
||||||
{
|
|
||||||
return string.Format("{0}:{1}()",
|
|
||||||
handler.Value.Method.DeclaringType.Name,
|
|
||||||
handler.Value.Method.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ShowServerMessageHandlers(Rect r, int posY)
|
|
||||||
{
|
|
||||||
if (NetworkServer.handlers.Count == 0)
|
|
||||||
return posY;
|
|
||||||
|
|
||||||
GUI.Label(new Rect(r.xMin + k_Padding, posY, 400, k_RowHeight), m_ShowServerMessagesLabel);
|
|
||||||
posY += k_RowHeight;
|
|
||||||
|
|
||||||
foreach (var handler in NetworkServer.handlers)
|
|
||||||
{
|
|
||||||
GUI.Label(new Rect(r.xMin + k_Padding * 4, posY, 400, k_RowHeight), ((MsgType)handler.Key).ToString());
|
|
||||||
GUI.Label(new Rect(r.xMin + k_Padding * 4 + k_ColumnWidth, posY, 400, k_RowHeight), FormatHandler(handler));
|
|
||||||
posY += k_RowHeight;
|
|
||||||
}
|
|
||||||
return posY;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ShowClientMessageHandlers(Rect r, int posY)
|
|
||||||
{
|
|
||||||
if (NetworkClient.allClients.Count == 0)
|
|
||||||
return posY;
|
|
||||||
|
|
||||||
NetworkClient client = NetworkClient.allClients[0];
|
|
||||||
if (client == null)
|
|
||||||
return posY;
|
|
||||||
|
|
||||||
GUI.Label(new Rect(r.xMin + k_Padding, posY, 400, k_RowHeight), m_ShowClientMessagesLabel);
|
|
||||||
posY += k_RowHeight;
|
|
||||||
|
|
||||||
foreach (var handler in client.handlers)
|
|
||||||
{
|
|
||||||
GUI.Label(new Rect(r.xMin + k_Padding * 4, posY, 400, k_RowHeight), ((MsgType)handler.Key).ToString());
|
|
||||||
GUI.Label(new Rect(r.xMin + k_Padding * 4 + k_ColumnWidth, posY, 400, k_RowHeight), FormatHandler(handler));
|
|
||||||
posY += k_RowHeight;
|
|
||||||
}
|
|
||||||
return posY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetNetworkInformation(NetworkManager man)
|
|
||||||
{
|
|
||||||
m_Manager = man;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user