1
- using MLAPI ;
1
+ using System . Collections . Generic ;
2
+ using MLAPI ;
2
3
using UnityEngine ;
3
4
4
5
namespace UnityEditor
@@ -9,6 +10,7 @@ public class NetworkedObjectEditor : Editor
9
10
{
10
11
private bool initialized ;
11
12
private NetworkedObject networkedObject ;
13
+ private bool showObservers ;
12
14
13
15
private void Init ( )
14
16
{
@@ -24,7 +26,7 @@ public override void OnInspectorGUI()
24
26
if ( NetworkingManager . Singleton == null || ( ! NetworkingManager . Singleton . IsServer && ! NetworkingManager . Singleton . IsClient ) )
25
27
base . OnInspectorGUI ( ) ; //Only run this if we are NOT running server. This is where the ServerOnly box is drawn
26
28
27
- if ( ! networkedObject . isSpawned && NetworkingManager . Singleton != null && NetworkingManager . Singleton . IsServer )
29
+ if ( ! networkedObject . IsSpawned && NetworkingManager . Singleton != null && NetworkingManager . Singleton . IsServer )
28
30
{
29
31
EditorGUILayout . BeginHorizontal ( ) ;
30
32
EditorGUILayout . LabelField ( new GUIContent ( "Spawn" , "Spawns the object across the network" ) ) ;
@@ -35,18 +37,40 @@ public override void OnInspectorGUI()
35
37
}
36
38
EditorGUILayout . EndHorizontal ( ) ;
37
39
}
38
- else if ( networkedObject . isSpawned )
40
+ else if ( networkedObject . IsSpawned )
39
41
{
40
42
EditorGUILayout . LabelField ( "PrefabName: " , networkedObject . NetworkedPrefabName , EditorStyles . label ) ;
41
43
EditorGUILayout . LabelField ( "PrefabHash: " , networkedObject . NetworkedPrefabHash . ToString ( ) , EditorStyles . label ) ;
42
44
EditorGUILayout . LabelField ( "NetworkId: " , networkedObject . NetworkId . ToString ( ) , EditorStyles . label ) ;
43
45
EditorGUILayout . LabelField ( "OwnerId: " , networkedObject . OwnerClientId . ToString ( ) , EditorStyles . label ) ;
44
- EditorGUILayout . LabelField ( "isSpawned: " , networkedObject . isSpawned . ToString ( ) , EditorStyles . label ) ;
45
- EditorGUILayout . LabelField ( "isLocalPlayer: " , networkedObject . isLocalPlayer . ToString ( ) , EditorStyles . label ) ;
46
- EditorGUILayout . LabelField ( "isOwner: " , networkedObject . isOwner . ToString ( ) , EditorStyles . label ) ;
47
- EditorGUILayout . LabelField ( "isOwnedByServer: " , networkedObject . isOwnedByServer . ToString ( ) , EditorStyles . label ) ;
48
- EditorGUILayout . LabelField ( "isPoolObject: " , networkedObject . isPooledObject . ToString ( ) , EditorStyles . label ) ;
49
- EditorGUILayout . LabelField ( "isPlayerObject: " , networkedObject . isPlayerObject . ToString ( ) , EditorStyles . label ) ;
46
+ EditorGUILayout . LabelField ( "IsSpawned: " , networkedObject . IsSpawned . ToString ( ) , EditorStyles . label ) ;
47
+ EditorGUILayout . LabelField ( "IsLocalPlayer: " , networkedObject . IsLocalPlayer . ToString ( ) , EditorStyles . label ) ;
48
+ EditorGUILayout . LabelField ( "IsOwner: " , networkedObject . IsOwner . ToString ( ) , EditorStyles . label ) ;
49
+ EditorGUILayout . LabelField ( "IsOwnedByServer: " , networkedObject . IsOwnedByServer . ToString ( ) , EditorStyles . label ) ;
50
+ EditorGUILayout . LabelField ( "IsPoolObject: " , networkedObject . IsPooledObject . ToString ( ) , EditorStyles . label ) ;
51
+ EditorGUILayout . LabelField ( "IsPlayerObject: " , networkedObject . IsPlayerObject . ToString ( ) , EditorStyles . label ) ;
52
+
53
+ if ( NetworkingManager . Singleton != null && NetworkingManager . Singleton . IsServer )
54
+ {
55
+ showObservers = EditorGUILayout . Foldout ( showObservers , "Observers" ) ;
56
+
57
+ if ( showObservers )
58
+ {
59
+ HashSet < uint > . Enumerator observerClientIds = networkedObject . GetObservers ( ) ;
60
+
61
+ EditorGUI . indentLevel += 1 ;
62
+
63
+ while ( observerClientIds . MoveNext ( ) )
64
+ {
65
+ if ( NetworkingManager . Singleton . ConnectedClients [ observerClientIds . Current ] . PlayerObject != null )
66
+ EditorGUILayout . ObjectField ( "ClientId: " + observerClientIds . Current , NetworkingManager . Singleton . ConnectedClients [ observerClientIds . Current ] . PlayerObject , typeof ( GameObject ) , false ) ;
67
+ else
68
+ EditorGUILayout . TextField ( "ClientId: " + observerClientIds . Current , EditorStyles . label ) ;
69
+ }
70
+
71
+ EditorGUI . indentLevel -= 1 ;
72
+ }
73
+ }
50
74
}
51
75
}
52
76
}
0 commit comments