Skip to content

Commit

Permalink
Fixed baking one object several times
Browse files Browse the repository at this point in the history
  • Loading branch information
akovnir-pq committed Jul 28, 2018
1 parent c017a98 commit eb2dd35
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions SimplestMeshBaker/Editor/MeshBaker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -26,6 +27,7 @@ enum Resolving
[MenuItem("GameObject/Bake Meshes", false, 0)]
private static void BakeMeshes(MenuCommand menuCommand)
{

if (Selection.objects.Length == 0)
{
return;
Expand Down Expand Up @@ -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<GameObject> gos = new HashSet<GameObject>();
foreach (GameObject selected in Selection.gameObjects)
{
if (selected != null)
if (selected != null && !gos.Contains(selected))
{
Undo.DestroyObjectImmediate(selected);
gos.Add(selected);
}
}
}
Expand Down

0 comments on commit eb2dd35

Please sign in to comment.