mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
* feat(NetworkManager): Clear Spawnable Prefabs button (#3619) * Update Assets/Mirror/Editor/NetworkManagerEditor.cs Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com> --------- Co-authored-by: mischa <info@noobtuts.com> Co-authored-by: MrGadget <9826063+MrGadget1024@users.noreply.github.com>
This commit is contained in:
parent
2d3c1e8ba1
commit
dec47b7b7d
@ -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:");
|
||||
|
Loading…
Reference in New Issue
Block a user