/// <summary> /// Import meshes, start from highest LOD and import the chain. /// </summary> public static void ProcessMeshes(JObject assetJson, string assetFolderPath, bool highpoly, bool hasVariations, PrefabData prefabData) { try { bool createPrefabs = EditorPrefs.GetBool("QuixelDefaultSetupPrefabs", true); bool importLODs = EditorPrefs.GetBool("QuixelDefaultImportLODs", true); bool setupLODs = EditorPrefs.GetBool("QuixelDefaultSetupLOD", true); prefabData.setupLODs = (importLODs && setupLODs); //Only do LOD setup if lower lods were imported and LOD grouping is enabled. //get mesh components from the current object. Also, meshComps.Count can give us the number of variations ;) JArray meshComps = (JArray)assetJson["meshList"]; JArray lodList = (JArray)assetJson["lodList"]; string activeLOD = (string)assetJson["activeLOD"]; string minLOD = (string)assetJson["minLOD"]; string modelsFolderPath = MegascansUtilities.ValidateFolderCreate(assetFolderPath, "Models"); if (hasVariations) { List <List <string> > importedGeometryPaths3DPlant = new List <List <string> >(); for (int i = 1; i <= meshComps.Count; i++) { List <string> importedGeometryPaths = new List <string>(); bool lodMatched = false; // This flag helps to import the lower lods once the active lod is found. foreach (JObject mesh in lodList) { if ((int)mesh["variation"] == i) { string currentLOD = (string)mesh["lod"]; if (lodMatched || currentLOD == activeLOD || highpoly) { lodMatched = true; if ((currentLOD == "high") && !highpoly) { continue; } //get the path of the highest LOD to be imported. string sourcePath = (string)mesh["path"]; string destPath = Path.Combine(modelsFolderPath, (string)mesh["nameOverride"]); ImportMesh(sourcePath, destPath); importedGeometryPaths.Add(destPath); if (!importLODs) { break; } } } } importedGeometryPaths3DPlant.Add(importedGeometryPaths); } prefabData.importedGeometryPaths3DPlant = importedGeometryPaths3DPlant; if (createPrefabs) { CreatePrefab3DPlant(prefabData); } } else { List <string> importedGeometryPaths3D = new List <string>(); bool lodMatched = false; // This flag helps to import the lower lods once the active lod is found. foreach (JObject mesh in lodList) { string currentLOD = (string)mesh["lod"]; if (lodMatched || (currentLOD == activeLOD) || highpoly) { lodMatched = true; if ((currentLOD == "high") && !highpoly) { continue; } //get the path of the highest LOD to be imported. string sourcePath = (string)mesh["path"]; string destPath = Path.Combine(modelsFolderPath, (string)mesh["nameOverride"]); ImportMesh(sourcePath, destPath); importedGeometryPaths3D.Add(destPath); if (!importLODs) { break; } } } prefabData.importedGeometryPaths3D = importedGeometryPaths3D; if (createPrefabs) { if (MegascansUtilities.isScatterAsset(assetJson, importedGeometryPaths3D)) { CreatePrefabsScatter(prefabData); } else { CreatePrefab3D(prefabData); } } } } catch (Exception ex) { Debug.Log("Exception::MegascansMeshUtils::Processing Meshes:: " + ex.ToString()); MegascansUtilities.HideProgressBar(); } }