public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b){ int staticCompare = 0; if (b.isStatic == true && a.isStatic == false){ staticCompare = -1; } if (b.isStatic == false && a.isStatic == true){ staticCompare = 1; } return staticCompare; }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b){ int renderTypeCompare = 0; if (b.isMeshRenderer == true && a.isMeshRenderer == false){ renderTypeCompare = -1; } if (b.isMeshRenderer == false && a.isMeshRenderer == true){ renderTypeCompare = 1; } return renderTypeCompare; }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b){ int alreadyAddedCompare = 0; if (b.alreadyInBakerList == true && a.alreadyInBakerList == false){ alreadyAddedCompare = -1; } if (b.alreadyInBakerList == false && a.alreadyInBakerList == true){ alreadyAddedCompare = 1; } return alreadyAddedCompare; }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b) { int alreadyAddedCompare = 0; if (b.alreadyInBakerList == true && a.alreadyInBakerList == false) { alreadyAddedCompare = -1; } if (b.alreadyInBakerList == false && a.alreadyInBakerList == true) { alreadyAddedCompare = 1; } return(alreadyAddedCompare); }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b) { int compareVal = 0; if (b.go.activeInHierarchy == true && a.go.activeInHierarchy == false) { compareVal = -1; } if (b.go.activeInHierarchy == false && a.go.activeInHierarchy == true) { compareVal = 1; } return(compareVal); }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b) { int staticCompare = 0; if (b.isStatic == true && a.isStatic == false) { staticCompare = -1; } if (b.isStatic == false && a.isStatic == true) { staticCompare = 1; } return(staticCompare); }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b) { int renderTypeCompare = 0; if (b.isMeshRenderer == true && a.isMeshRenderer == false) { renderTypeCompare = -1; } if (b.isMeshRenderer == false && a.isMeshRenderer == true) { renderTypeCompare = 1; } return(renderTypeCompare); }
bool MaterialsAreTheSame(GameObjectFilterInfo a, GameObjectFilterInfo b) { HashSet <Material> aMats = new HashSet <Material>(); for (int i = 0; i < a.materials.Length; i++) { aMats.Add(a.materials[i]); } HashSet <Material> bMats = new HashSet <Material>(); for (int i = 0; i < b.materials.Length; i++) { bMats.Add(b.materials[i]); } return(aMats.SetEquals(bMats)); }
bool ShadersAreTheSame(GameObjectFilterInfo a, GameObjectFilterInfo b) { HashSet <Shader> aMats = new HashSet <Shader>(); for (int i = 0; i < a.shaders.Length; i++) { aMats.Add(a.shaders[i]); } HashSet <Shader> bMats = new HashSet <Shader>(); for (int i = 0; i < b.shaders.Length; i++) { bMats.Add(b.shaders[i]); } return(aMats.SetEquals(bMats)); }
void sortIntoBakeGroups3(List <GameObjectFilterInfo> gameObjects, Dictionary <GameObjectFilterInfo, List <GameObjectFilterInfo> > gs2bakeGroupMap, List <GameObjectFilterInfo> objsNotAddedToBaker) { List <GameObjectFilterInfo> gos = gameObjects; if (gos.Count < 1) { return; } List <IGroupByFilter> gbfs = new List <IGroupByFilter>(); for (int i = 0; i < groupByFilterIdxs.Length; i++) { if (groupByFilterIdxs[i] != 0) { gbfs.Add(groupByOptionFilters[groupByFilterIdxs[i]]); } } GameObjectFilterInfo.filters = gbfs.ToArray(); gos.Sort(); List <GameObjectFilterInfo> l = null; GameObjectFilterInfo key = gos[0]; Debug.Log("-----------"); for (int i = 0; i < gos.Count; i++) { GameObjectFilterInfo goaw = gos[i]; //compare with key and decide if we need a new list for (int j = 0; j < GameObjectFilterInfo.filters.Length; j++) { if (GameObjectFilterInfo.filters[j] != null && GameObjectFilterInfo.filters[j].Compare(key, goaw) != 0) { l = null; } } if (l == null) { l = new List <GameObjectFilterInfo>(); gs2bakeGroupMap.Add(gos[i], l); key = gos[i]; } l.Add(gos[i]); } }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b) { return(a.standardShaderBlendModesName.CompareTo(b.standardShaderBlendModesName)); }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b){ return Convert.ToInt32(b.outOfBoundsUVs) - Convert.ToInt32(a.outOfBoundsUVs); }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b) { return(b.lightmapIndex - a.lightmapIndex); }
void listMaterialsInScene() { if (!ValidateGroupByFields()) { return; } if (groupByOptionFilters == null) { populateGroupByFilters(); } //Get All Objects Already In a list of objects to be combined MB3_MeshBakerRoot[] allBakers = FindObjectsOfType <MB3_MeshBakerRoot>(); HashSet <GameObject> objectsAlreadyIncludedInBakers = new HashSet <GameObject>(); for (int i = 0; i < allBakers.Length; i++) { List <GameObject> objsToCombine = allBakers[i].GetObjectsToCombine(); for (int j = 0; j < objsToCombine.Count; j++) { if (objsToCombine[j] != null) { objectsAlreadyIncludedInBakers.Add(objsToCombine[j]); } } } List <GameObjectFilterInfo> gameObjects = new List <GameObjectFilterInfo>(); Renderer[] rs = (Renderer[])FindObjectsOfType(typeof(Renderer)); // Profile.StartProfile("listMaterialsInScene1"); EditorUtility.DisplayProgressBar("Analysing Scene", "Collecting Renderers", .25f); for (int i = 0; i < rs.Length; i++) { Renderer r = rs[i]; if (r is MeshRenderer || r is SkinnedMeshRenderer) { if (r.GetComponent <TextMesh>() != null) { continue; //don't add TextMeshes } GameObjectFilterInfo goaw = new GameObjectFilterInfo(r.gameObject, objectsAlreadyIncludedInBakers); gameObjects.Add(goaw); EditorUtility.DisplayProgressBar("Analysing Scene", "Collecting Renderer For " + r.name, .1f); } } Dictionary <int, MB_Utility.MeshAnalysisResult> meshAnalysisResultCache = new Dictionary <int, MB_Utility.MeshAnalysisResult>(); int totalVerts = 0; for (int i = 0; i < gameObjects.Count; i++) { string rpt = String.Format("Processing {0} [{1} of {2}]", gameObjects[i].go.name, i, gameObjects.Count); EditorUtility.DisplayProgressBar("Analysing Scene", rpt + " A", .6f); Mesh mm = MB_Utility.GetMesh(gameObjects[i].go); int nVerts = 0; if (mm != null) { nVerts += mm.vertexCount; MB_Utility.MeshAnalysisResult mar; if (!meshAnalysisResultCache.TryGetValue(mm.GetInstanceID(), out mar)) { EditorUtility.DisplayProgressBar("Analysing Scene", rpt + " Check Out Of Bounds UVs", .6f); MB_Utility.hasOutOfBoundsUVs(mm, ref mar); //Rect dummy = mar.uvRect; MB_Utility.doSubmeshesShareVertsOrTris(mm, ref mar); meshAnalysisResultCache.Add(mm.GetInstanceID(), mar); } if (mar.hasOutOfBoundsUVs) { int w = (int)mar.uvRect.width; int h = (int)mar.uvRect.height; gameObjects[i].outOfBoundsUVs = true; gameObjects[i].warning += " [WARNING: has uvs outside the range (0,1) tex is tiled " + w + "x" + h + " times]"; } if (mar.hasOverlappingSubmeshVerts) { gameObjects[i].submeshesOverlap = true; gameObjects[i].warning += " [WARNING: Submeshes share verts or triangles. 'Multiple Combined Materials' feature may not work.]"; } } totalVerts += nVerts; EditorUtility.DisplayProgressBar("Analysing Scene", rpt + " Validate OBuvs Multi Material", .6f); Renderer mr = gameObjects[i].go.GetComponent <Renderer>(); if (!MB_Utility.AreAllSharedMaterialsDistinct(mr.sharedMaterials)) { gameObjects[i].warning += " [WARNING: Object uses same material on multiple submeshes. This may produce poor results when used with multiple materials or fix out of bounds uvs.]"; } } Dictionary <GameObjectFilterInfo, List <GameObjectFilterInfo> > gs2bakeGroupMap = new Dictionary <GameObjectFilterInfo, List <GameObjectFilterInfo> >(); List <GameObjectFilterInfo> objsNotAddedToBaker = new List <GameObjectFilterInfo>(); sortIntoBakeGroups3(gameObjects, gs2bakeGroupMap, objsNotAddedToBaker); sceneAnalysisResults = new List <List <GameObjectFilterInfo> >(); sceneAnalysisResultsFoldouts = new bool[gs2bakeGroupMap.Keys.Count]; int ii = 0; foreach (GameObjectFilterInfo gow in gs2bakeGroupMap.Keys) { sceneAnalysisResultsFoldouts[ii++] = true; List <GameObjectFilterInfo> gows = gs2bakeGroupMap[gow]; sceneAnalysisResults.Add(gows); } // if (generateMeshBakers){ // createBakers(gs2bakeGroupMap, objsNotAddedToBaker); // } else { string fileName = Application.dataPath + "/MeshBakerSceneAnalysisReport.txt"; try{ System.IO.File.WriteAllText(fileName, generateSceneAnalysisReport(gs2bakeGroupMap, objsNotAddedToBaker)); Debug.Log(String.Format("Wrote scene analysis file to '{0}'. This file contains a list of all renderers and the materials/shaders that they use. It is designed to be opened with a spreadsheet.", fileName)); } catch (Exception e) { e.GetHashCode(); //supress compiler warning Debug.Log("Failed to write file: " + fileName); } // } }
public string GetDescription(GameObjectFilterInfo fi){ return "shader=" + fi.shaderName; }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b) { return(a.materialName.CompareTo(b.materialName)); }
public string GetDescription(GameObjectFilterInfo fi){ return "OutOfBoundsUVs=" + fi.outOfBoundsUVs; }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b){ return a.shaderName.CompareTo(b.shaderName); }
bool ShadersAreTheSame(GameObjectFilterInfo a, GameObjectFilterInfo b){ HashSet<Shader> aMats = new HashSet<Shader>(); for(int i = 0; i < a.shaders.Length; i++) aMats.Add(a.shaders[i]); HashSet<Shader> bMats = new HashSet<Shader>(); for(int i = 0; i < b.shaders.Length; i++) bMats.Add(b.shaders[i]); return aMats.SetEquals(bMats); }
public string GetDescription(GameObjectFilterInfo fi){ return fi.isMeshRenderer ? "MeshRenderer" : "SkinnedMeshRenderer"; }
bool MaterialsAreTheSame(GameObjectFilterInfo a, GameObjectFilterInfo b){ HashSet<Material> aMats = new HashSet<Material>(); for(int i = 0; i < a.materials.Length; i++) aMats.Add(a.materials[i]); HashSet<Material> bMats = new HashSet<Material>(); for(int i = 0; i < b.materials.Length; i++) bMats.Add(b.materials[i]); return aMats.SetEquals(bMats); }
void listMaterialsInScene(){ if (!ValidateGroupByFields()) return; //Get All Objects Already In a list of objects to be combined MB3_MeshBakerRoot[] allBakers = FindObjectsOfType<MB3_MeshBakerRoot>(); HashSet<GameObject> objectsAlreadyIncludedInBakers = new HashSet<GameObject>(); for (int i = 0; i < allBakers.Length; i++){ List<GameObject> objsToCombine = allBakers[i].GetObjectsToCombine(); for (int j = 0; j < objsToCombine.Count; j++){ if (objsToCombine[j] != null) objectsAlreadyIncludedInBakers.Add(objsToCombine[j]); } } List<GameObjectFilterInfo> gameObjects = new List<GameObjectFilterInfo>(); Renderer[] rs = (Renderer[]) FindObjectsOfType(typeof(Renderer)); // Profile.StartProfile("listMaterialsInScene1"); EditorUtility.DisplayProgressBar("Analysing Scene","Collecting Renderers",.25f); for (int i = 0; i < rs.Length; i++){ Renderer r = rs[i]; if (r is MeshRenderer || r is SkinnedMeshRenderer){ if (r.GetComponent<TextMesh>() != null){ continue; //don't add TextMeshes } GameObjectFilterInfo goaw = new GameObjectFilterInfo(r.gameObject,objectsAlreadyIncludedInBakers); gameObjects.Add (goaw); EditorUtility.DisplayProgressBar("Analysing Scene","Collecting Renderer For " + r.name,.1f); } } Dictionary<int,MB_Utility.MeshAnalysisResult> meshAnalysisResultCache = new Dictionary<int, MB_Utility.MeshAnalysisResult>(); int totalVerts = 0; for (int i = 0; i < gameObjects.Count; i++){ string rpt = String.Format ("Processing {0} [{1} of {2}]",gameObjects[i].go.name,i,gameObjects.Count); EditorUtility.DisplayProgressBar("Analysing Scene",rpt + " A",.6f); Mesh mm = MB_Utility.GetMesh(gameObjects[i].go); int nVerts = 0; if (mm != null){ nVerts += mm.vertexCount; MB_Utility.MeshAnalysisResult mar; if (!meshAnalysisResultCache.TryGetValue(mm.GetInstanceID(),out mar)){ Rect dummy = new Rect(); EditorUtility.DisplayProgressBar("Analysing Scene",rpt + " Check Out Of Bounds UVs",.6f); MB_Utility.hasOutOfBoundsUVs(mm,ref dummy,ref mar); MB_Utility.doSubmeshesShareVertsOrTris(mm,ref mar); meshAnalysisResultCache.Add (mm.GetInstanceID(),mar); } if (mar.hasOutOfBoundsUVs){ int w = (int) mar.uvRect.width; int h = (int) mar.uvRect.height; gameObjects[i].outOfBoundsUVs = true; gameObjects[i].warning += " [WARNING: has uvs outside the range (0,1) tex is tiled " + w + "x" + h + " times]"; } if (mar.hasOverlappingSubmeshVerts){ gameObjects[i].submeshesOverlap = true; gameObjects[i].warning += " [WARNING: Submeshes share verts or triangles. 'Multiple Combined Materials' feature may not work.]"; } } totalVerts += nVerts; EditorUtility.DisplayProgressBar("Analysing Scene",rpt + " Validate OBuvs Multi Material",.6f); Renderer mr = gameObjects[i].go.GetComponent<Renderer>(); if (!MB_Utility.AreAllSharedMaterialsDistinct(mr.sharedMaterials)){ gameObjects[i].warning += " [WARNING: Object uses same material on multiple submeshes. This may produce poor results when used with multiple materials or fix out of bounds uvs.]"; } } Dictionary<GameObjectFilterInfo,List<GameObjectFilterInfo>> gs2bakeGroupMap = new Dictionary<GameObjectFilterInfo,List<GameObjectFilterInfo>>(); List<GameObjectFilterInfo> objsNotAddedToBaker = new List<GameObjectFilterInfo>(); sortIntoBakeGroups3(gameObjects, gs2bakeGroupMap, objsNotAddedToBaker); sceneAnalysisResults = new List<List<GameObjectFilterInfo>>(); sceneAnalysisResultsFoldouts = new bool[gs2bakeGroupMap.Keys.Count]; int ii = 0; foreach (GameObjectFilterInfo gow in gs2bakeGroupMap.Keys){ sceneAnalysisResultsFoldouts[ii++] = true; List<GameObjectFilterInfo> gows = gs2bakeGroupMap[gow]; sceneAnalysisResults.Add (gows); } // if (generateMeshBakers){ // createBakers(gs2bakeGroupMap, objsNotAddedToBaker); // } else { Debug.Log( generateSceneAnalysisReport(gs2bakeGroupMap, objsNotAddedToBaker) ); // } }
public string GetDescription(GameObjectFilterInfo fi) { return("[RenderType] : " + (fi.isMeshRenderer ? "MeshRenderer" : "SkinnedMeshRenderer")); }
public string GetDescription(GameObjectFilterInfo fi) { return("[Shader] : " + fi.shaderName); }
public string GetDescription(GameObjectFilterInfo fi){ return "alreadyAdded=" + fi.alreadyInBakerList; }
/* tried to see if the MultiMaterialConfig could be done using the GroupBy filters. Saddly it didn't work */ public static void ConfigureMutiMaterialsFromObjsToCombine2(MB3_TextureBaker mom, SerializedProperty resultMaterials, SerializedObject textureBaker) { if (mom.GetObjectsToCombine().Count == 0) { Debug.LogError("You need to add some objects to combine before building the multi material list."); return; } if (resultMaterials.arraySize > 0) { Debug.LogError("You already have some source to combined material mappings configured. You must remove these before doing this operation."); return; } if (mom.textureBakeResults == null) { Debug.LogError("Texture Bake Result asset must be set before using this operation."); return; } //validate that the objects to be combined are valid for (int i = 0; i < mom.GetObjectsToCombine().Count; i++) { GameObject go = mom.GetObjectsToCombine()[i]; if (go == null) { Debug.LogError("Null object in list of objects to combine at position " + i); return; } Renderer r = go.GetComponent <Renderer>(); if (r == null || (!(r is MeshRenderer) && !(r is SkinnedMeshRenderer))) { Debug.LogError("GameObject at position " + i + " in list of objects to combine did not have a renderer"); return; } if (r.sharedMaterial == null) { Debug.LogError("GameObject at position " + i + " in list of objects to combine has a null material"); return; } } IGroupByFilter[] filters = new IGroupByFilter[3]; filters[0] = new GroupByOutOfBoundsUVs(); filters[1] = new GroupByShader(); filters[2] = new MB3_GroupByStandardShaderType(); List <GameObjectFilterInfo> gameObjects = new List <GameObjectFilterInfo>(); HashSet <GameObject> objectsAlreadyIncludedInBakers = new HashSet <GameObject>(); for (int i = 0; i < mom.GetObjectsToCombine().Count; i++) { GameObjectFilterInfo goaw = new GameObjectFilterInfo(mom.GetObjectsToCombine()[i], objectsAlreadyIncludedInBakers, filters); if (goaw.materials.Length > 0) //don't consider renderers with no materials { gameObjects.Add(goaw); } } //analyse meshes Dictionary <int, MB_Utility.MeshAnalysisResult> meshAnalysisResultCache = new Dictionary <int, MB_Utility.MeshAnalysisResult>(); int totalVerts = 0; for (int i = 0; i < gameObjects.Count; i++) { //string rpt = String.Format("Processing {0} [{1} of {2}]", gameObjects[i].go.name, i, gameObjects.Count); //EditorUtility.DisplayProgressBar("Analysing Scene", rpt + " A", .6f); Mesh mm = MB_Utility.GetMesh(gameObjects[i].go); int nVerts = 0; if (mm != null) { nVerts += mm.vertexCount; MB_Utility.MeshAnalysisResult mar; if (!meshAnalysisResultCache.TryGetValue(mm.GetInstanceID(), out mar)) { //EditorUtility.DisplayProgressBar("Analysing Scene", rpt + " Check Out Of Bounds UVs", .6f); MB_Utility.hasOutOfBoundsUVs(mm, ref mar); //Rect dummy = mar.uvRect; MB_Utility.doSubmeshesShareVertsOrTris(mm, ref mar); meshAnalysisResultCache.Add(mm.GetInstanceID(), mar); } if (mar.hasOutOfBoundsUVs) { int w = (int)mar.uvRect.width; int h = (int)mar.uvRect.height; gameObjects[i].outOfBoundsUVs = true; gameObjects[i].warning += " [WARNING: has uvs outside the range (0,1) tex is tiled " + w + "x" + h + " times]"; } if (mar.hasOverlappingSubmeshVerts) { gameObjects[i].submeshesOverlap = true; gameObjects[i].warning += " [WARNING: Submeshes share verts or triangles. 'Multiple Combined Materials' feature may not work.]"; } } totalVerts += nVerts; //EditorUtility.DisplayProgressBar("Analysing Scene", rpt + " Validate OBuvs Multi Material", .6f); Renderer mr = gameObjects[i].go.GetComponent <Renderer>(); if (!MB_Utility.AreAllSharedMaterialsDistinct(mr.sharedMaterials)) { gameObjects[i].warning += " [WARNING: Object uses same material on multiple submeshes. This may produce poor results when used with multiple materials or fix out of bounds uvs.]"; } } List <GameObjectFilterInfo> objsNotAddedToBaker = new List <GameObjectFilterInfo>(); Dictionary <GameObjectFilterInfo, List <List <GameObjectFilterInfo> > > gs2bakeGroupMap = MB3_MeshBakerEditorWindow.sortIntoBakeGroups3(gameObjects, objsNotAddedToBaker, filters, false, mom.maxAtlasSize); mom.resultMaterials = new MB_MultiMaterial[gs2bakeGroupMap.Keys.Count]; string pth = AssetDatabase.GetAssetPath(mom.textureBakeResults); string baseName = Path.GetFileNameWithoutExtension(pth); string folderPath = pth.Substring(0, pth.Length - baseName.Length - 6); int k = 0; foreach (GameObjectFilterInfo m in gs2bakeGroupMap.Keys) { MB_MultiMaterial mm = mom.resultMaterials[k] = new MB_MultiMaterial(); mm.sourceMaterials = new List <Material>(); mm.sourceMaterials.Add(m.materials[0]); string matName = folderPath + baseName + "-mat" + k + ".mat"; Material newMat = new Material(Shader.Find("Diffuse")); MB3_TextureBaker.ConfigureNewMaterialToMatchOld(newMat, m.materials[0]); AssetDatabase.CreateAsset(newMat, matName); mm.combinedMaterial = (Material)AssetDatabase.LoadAssetAtPath(matName, typeof(Material)); k++; } MBVersionEditor.UpdateIfDirtyOrScript(textureBaker); }
public string GetDescription(GameObjectFilterInfo fi) { return("[alreadyAdded] : " + fi.alreadyInBakerList); }
public string GetDescription(GameObjectFilterInfo fi) { return(fi.go.activeInHierarchy ? "Enabled" : "Disabled"); }
public string GetDescription(GameObjectFilterInfo fi){ return "material=" + fi.materialName; }
public string GetDescription(GameObjectFilterInfo fi) { return("[isStatic] : " + fi.isStatic); }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b){ return a.materialName.CompareTo(b.materialName); }
public string GetDescription(GameObjectFilterInfo fi) { return("[material] : " + fi.materialName); }
public string GetDescription(GameObjectFilterInfo fi){ return "lightmapIndex=" + fi.lightmapIndex; }
public string GetDescription(GameObjectFilterInfo fi) { return("[lightmapIndex] : " + fi.lightmapIndex); }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b){ return b.lightmapIndex - a.lightmapIndex; }
public string GetDescription(GameObjectFilterInfo fi) { return("renderingMode=" + fi.standardShaderBlendModesName); }
public int Compare(GameObjectFilterInfo a, GameObjectFilterInfo b) { return(a.shaderName.CompareTo(b.shaderName)); }
public string GetDescription(GameObjectFilterInfo fi){ return "isStatic=" + fi.isStatic; }
public static Dictionary <GameObjectFilterInfo, List <List <GameObjectFilterInfo> > > sortIntoBakeGroups3(List <GameObjectFilterInfo> gameObjects, List <GameObjectFilterInfo> objsNotAddedToBaker, IGroupByFilter[] filters, bool splitAtlasesSoMeshesFit, int atlasSize) { Dictionary <GameObjectFilterInfo, List <List <GameObjectFilterInfo> > > gs2bakeGroupMap = new Dictionary <GameObjectFilterInfo, List <List <GameObjectFilterInfo> > >(); List <GameObjectFilterInfo> gos = gameObjects; if (gos.Count < 1) { return(gs2bakeGroupMap); } gos.Sort(); List <List <GameObjectFilterInfo> > l = null; GameObjectFilterInfo key = gos[0]; for (int i = 0; i < gos.Count; i++) { GameObjectFilterInfo goaw = gos[i]; //compare with key and decide if we need a new list for (int j = 0; j < filters.Length; j++) { if (filters[j] != null && filters[j].Compare(key, goaw) != 0) { l = null; } } if (l == null) { l = new List <List <GameObjectFilterInfo> >(); l.Add(new List <GameObjectFilterInfo>()); gs2bakeGroupMap.Add(gos[i], l); key = gos[i]; } l[0].Add(gos[i]); } //now that objects have been grouped by the sort criteria we can see how many atlases are needed Dictionary <GameObjectFilterInfo, List <List <GameObjectFilterInfo> > > gs2bakeGroupMap2 = new Dictionary <GameObjectFilterInfo, List <List <GameObjectFilterInfo> > >(); if (splitAtlasesSoMeshesFit) { foreach (GameObjectFilterInfo k in gs2bakeGroupMap.Keys) { List <GameObjectFilterInfo> vs = gs2bakeGroupMap[k][0]; List <GameObject> objsInGroup = new List <GameObject>(); for (int i = 0; i < vs.Count; i++) { objsInGroup.Add(vs[i].go); } MB3_TextureCombiner tc = new MB3_TextureCombiner(); tc.maxAtlasSize = atlasSize; tc.packingAlgorithm = MB2_PackingAlgorithmEnum.MeshBakerTexturePacker; tc.LOG_LEVEL = MB2_LogLevel.warn; List <AtlasPackingResult> packingResults = new List <AtlasPackingResult>(); Material tempResMat = k.materials[0];//we don't write to the materials so can use this as the result material MB_AtlasesAndRects tempAtlasesAndRects = new MB_AtlasesAndRects(); if (tc.CombineTexturesIntoAtlases(null, tempAtlasesAndRects, tempResMat, objsInGroup, null, null, packingResults, onlyPackRects:true, splitAtlasWhenPackingIfTooBig:false)) { List <List <GameObjectFilterInfo> > atlasGroups = new List <List <GameObjectFilterInfo> >(); for (int i = 0; i < packingResults.Count; i++) { List <GameObjectFilterInfo> ngos = new List <GameObjectFilterInfo>(); List <MB_MaterialAndUVRect> matsData = (List <MB_MaterialAndUVRect>)packingResults[i].data; for (int j = 0; j < matsData.Count; j++) { for (int kk = 0; kk < matsData[j].objectsThatUse.Count; kk++) { GameObjectFilterInfo gofi = vs.Find(x => x.go == matsData[j].objectsThatUse[kk]); //Debug.Assert(gofi != null); ngos.Add(gofi); } } ngos[0].atlasIndex = (short)i; atlasGroups.Add(ngos); } gs2bakeGroupMap2.Add(k, atlasGroups); } else { gs2bakeGroupMap2.Add(k, gs2bakeGroupMap[k]); } } } else { gs2bakeGroupMap2 = gs2bakeGroupMap; } return(gs2bakeGroupMap2); }