diff --git a/Assets/Mirror/Editor/NetworkManagerEditor.cs b/Assets/Mirror/Editor/NetworkManagerEditor.cs index 82b2b1b9f..a7aa9bc58 100644 --- a/Assets/Mirror/Editor/NetworkManagerEditor.cs +++ b/Assets/Mirror/Editor/NetworkManagerEditor.cs @@ -50,6 +50,15 @@ public override void OnInspectorGUI() { ScanForNetworkIdentities(); } + + // clicking the Populate button in a large project can add hundreds of entries. + // have a clear button in case that wasn't intended. + GUI.enabled = networkManager.spawnPrefabs.Count > 0; + if (GUILayout.Button("Clear Spawnable Prefabs")) + { + ClearNetworkIdentities(); + } + GUI.enabled = true; } void ScanForNetworkIdentities() @@ -117,6 +126,19 @@ void ScanForNetworkIdentities() } } + void ClearNetworkIdentities() + { + // RecordObject is needed for "*" to show up in Scene. + // however, this only saves List.Count without the entries. + Undo.RecordObject(networkManager, "NetworkManager: cleared prefabs"); + + // add the entries + networkManager.spawnPrefabs.Clear(); + + // SetDirty is required to save the individual entries properly. + EditorUtility.SetDirty(target); + } + static void DrawHeader(Rect headerRect) { GUI.Label(headerRect, "Registered Spawnable Prefabs:");