1- using MLAPI ;
1+ using System . Collections . Generic ;
2+ using MLAPI ;
23using UnityEngine ;
34
45namespace UnityEditor
@@ -9,6 +10,7 @@ public class NetworkedObjectEditor : Editor
910 {
1011 private bool initialized ;
1112 private NetworkedObject networkedObject ;
13+ private bool showObservers ;
1214
1315 private void Init ( )
1416 {
@@ -24,7 +26,7 @@ public override void OnInspectorGUI()
2426 if ( NetworkingManager . Singleton == null || ( ! NetworkingManager . Singleton . IsServer && ! NetworkingManager . Singleton . IsClient ) )
2527 base . OnInspectorGUI ( ) ; //Only run this if we are NOT running server. This is where the ServerOnly box is drawn
2628
27- if ( ! networkedObject . isSpawned && NetworkingManager . Singleton != null && NetworkingManager . Singleton . IsServer )
29+ if ( ! networkedObject . IsSpawned && NetworkingManager . Singleton != null && NetworkingManager . Singleton . IsServer )
2830 {
2931 EditorGUILayout . BeginHorizontal ( ) ;
3032 EditorGUILayout . LabelField ( new GUIContent ( "Spawn" , "Spawns the object across the network" ) ) ;
@@ -35,18 +37,40 @@ public override void OnInspectorGUI()
3537 }
3638 EditorGUILayout . EndHorizontal ( ) ;
3739 }
38- else if ( networkedObject . isSpawned )
40+ else if ( networkedObject . IsSpawned )
3941 {
4042 EditorGUILayout . LabelField ( "PrefabName: " , networkedObject . NetworkedPrefabName , EditorStyles . label ) ;
4143 EditorGUILayout . LabelField ( "PrefabHash: " , networkedObject . NetworkedPrefabHash . ToString ( ) , EditorStyles . label ) ;
4244 EditorGUILayout . LabelField ( "NetworkId: " , networkedObject . NetworkId . ToString ( ) , EditorStyles . label ) ;
4345 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+ }
5074 }
5175 }
5276 }
0 commit comments