Skip to content

Commit f70a75f

Browse files
authored
fix: do not access/render runtime info if not playing in the editor (#898)
1 parent 28e1d85 commit f70a75f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

com.unity.multiplayer.mlapi/Editor/NetworkBehaviourEditor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,12 @@ public override void OnInspectorGUI()
174174
EditorGUI.BeginChangeCheck();
175175
serializedObject.Update();
176176

177-
for (int i = 0; i < m_NetworkVariableNames.Count; i++)
177+
if (EditorApplication.isPlaying)
178178
{
179-
RenderNetworkVariable(i);
179+
for (int i = 0; i < m_NetworkVariableNames.Count; i++)
180+
{
181+
RenderNetworkVariable(i);
182+
}
180183
}
181184

182185
var property = serializedObject.GetIterator();

com.unity.multiplayer.mlapi/Editor/NetworkObjectEditor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override void OnInspectorGUI()
2727
{
2828
Initialize();
2929

30-
if (!m_NetworkObject.IsSpawned && m_NetworkObject.NetworkManager != null && m_NetworkObject.NetworkManager.IsServer)
30+
if (EditorApplication.isPlaying && !m_NetworkObject.IsSpawned && m_NetworkObject.NetworkManager != null && m_NetworkObject.NetworkManager.IsServer)
3131
{
3232
EditorGUILayout.BeginHorizontal();
3333
EditorGUILayout.LabelField(new GUIContent("Spawn", "Spawns the object across the network"));
@@ -39,7 +39,7 @@ public override void OnInspectorGUI()
3939

4040
EditorGUILayout.EndHorizontal();
4141
}
42-
else if (m_NetworkObject.IsSpawned)
42+
else if (EditorApplication.isPlaying && m_NetworkObject.IsSpawned)
4343
{
4444
var guiEnabled = GUI.enabled;
4545
GUI.enabled = false;

0 commit comments

Comments
 (0)