From eb2dd35b3e23fa388cea3941600fee2fc19c330d Mon Sep 17 00:00:00 2001 From: Albert Date: Sat, 28 Jul 2018 12:36:06 +0300 Subject: [PATCH] Fixed baking one object several times --- SimplestMeshBaker/Editor/MeshBaker.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SimplestMeshBaker/Editor/MeshBaker.cs b/SimplestMeshBaker/Editor/MeshBaker.cs index 383f277..16acb08 100644 --- a/SimplestMeshBaker/Editor/MeshBaker.cs +++ b/SimplestMeshBaker/Editor/MeshBaker.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; @@ -26,6 +27,7 @@ enum Resolving [MenuItem("GameObject/Bake Meshes", false, 0)] private static void BakeMeshes(MenuCommand menuCommand) { + if (Selection.objects.Length == 0) { return; @@ -131,11 +133,13 @@ private static void BakeMeshes(MenuCommand menuCommand) if (EditorUtility.DisplayDialog("Simplest Mesh Baker", "Do you want to remove sources?", "Yes", "No")) { + HashSet gos = new HashSet(); foreach (GameObject selected in Selection.gameObjects) { - if (selected != null) + if (selected != null && !gos.Contains(selected)) { Undo.DestroyObjectImmediate(selected); + gos.Add(selected); } } }