Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,12 @@ public override void OnInspectorGUI()
EditorGUI.BeginChangeCheck();
serializedObject.Update();

for (int i = 0; i < m_NetworkVariableNames.Count; i++)
if (EditorApplication.isPlaying)
{
RenderNetworkVariable(i);
for (int i = 0; i < m_NetworkVariableNames.Count; i++)
{
RenderNetworkVariable(i);
}
}

var property = serializedObject.GetIterator();
Expand Down
4 changes: 2 additions & 2 deletions com.unity.multiplayer.mlapi/Editor/NetworkObjectEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override void OnInspectorGUI()
{
Initialize();

if (!m_NetworkObject.IsSpawned && m_NetworkObject.NetworkManager != null && m_NetworkObject.NetworkManager.IsServer)
if (EditorApplication.isPlaying && !m_NetworkObject.IsSpawned && m_NetworkObject.NetworkManager != null && m_NetworkObject.NetworkManager.IsServer)
Copy link
Contributor

@jeffreyrainy jeffreyrainy Jun 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be safer to do:
if (EditorApplication.isPlaying && m_NetworkObject != null && !m_NetworkObject.IsSpawned && m_NetworkObject.NetworkManager != null && m_NetworkObject.NetworkManager.IsServer)
e.g. checking that the m_NetworkObject is set ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_NetworkObject is coming from UnityEditor.Editor::target (maybe see Initialize())

{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(new GUIContent("Spawn", "Spawns the object across the network"));
Expand All @@ -39,7 +39,7 @@ public override void OnInspectorGUI()

EditorGUILayout.EndHorizontal();
}
else if (m_NetworkObject.IsSpawned)
else if (EditorApplication.isPlaying && m_NetworkObject.IsSpawned)
Copy link
Contributor

@jeffreyrainy jeffreyrainy Jun 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: && m_NetworkObject != null in the middle ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ see above

{
var guiEnabled = GUI.enabled;
GUI.enabled = false;
Expand Down