public override string ToString() { return(string.Format( "{0} ({1}) S:[{2} - {3}] ({4}) ({5})", Point, IsStart ? "left" : "right", Point, OtherEvent.Point, PolygonType.ToString().ToUpper(), EdgeType.ToString().ToUpper() )); }
private static void CreatePrefabsWithDataGroup(List <BlockDataGroup> blockDataGroups, Category category, PolygonType polygonType) { string prefabDir = BlockPath.Prefab(category, polygonType); string fbxDir = BlockPath.Fbx(category, polygonType); string matDir = BlockPath.Material(category, polygonType); List <string> fbxErrors = new List <string>(); List <string> scaleErrors = new List <string>(); List <string> angleErrors = new List <string>(); List <string> materialErrors = new List <string>(); for (int i = 0; i < blockDataGroups.Count; i++) { EditorUtility.DisplayProgressBar(string.Format("生成 {0} Prefabs", polygonType.ToString()), "正在生成,请稍后", i * 1.0f / blockDataGroups.Count); BlockDataGroup blockDataGroup = blockDataGroups[i]; foreach (var dataItem in blockDataGroup.GetItems()) { GameObject t = AssetDatabase.LoadAssetAtPath <GameObject>(fbxDir + "/" + blockDataGroup.modelName + ".fbx"); if (t == null) { if (!fbxErrors.Contains(blockDataGroup.modelName)) { fbxErrors.Add(blockDataGroup.modelName); } continue; } GameObject block = GameObject.Instantiate(t); block.name = blockDataGroup.modelName; Animator animator = block.GetComponent <Animator>(); if (animator != null) { GameObject.DestroyImmediate(animator); } if (polygonType == PolygonType.LOW) { AssignMaterials(block, dataItem.material, matDir, materialErrors); } else { AssignMaterials(block, dataItem.materialHigh, matDir, materialErrors); HighPolygonGenRefpoints(block, category); } if (!Directory.Exists(prefabDir)) { Directory.CreateDirectory(prefabDir); } PrefabUtility.CreatePrefab(prefabDir + "/" + dataItem.prefabName + ".prefab", block, ReplacePrefabOptions.ReplaceNameBased); if (block.transform.localScale != Vector3.one) { if (!scaleErrors.Contains(blockDataGroup.modelName)) { scaleErrors.Add(blockDataGroup.modelName); } } if (block.transform.localEulerAngles != Vector3.zero) { if (!angleErrors.Contains(blockDataGroup.modelName)) { angleErrors.Add(blockDataGroup.modelName); } } GameObject.DestroyImmediate(block); } } EditorUtility.ClearProgressBar(); if (fbxErrors.Count > 0) { DisplayErrorDialog(polygonType.ToString() + " 找不到以下fbx\n", fbxErrors); } if (scaleErrors.Count > 0) { DisplayErrorDialog("以下fbx的默认scale不为1\n", scaleErrors); } if (angleErrors.Count > 0) { DisplayErrorDialog("以下fbx的默认角度不为0\n", angleErrors); } if (materialErrors.Count > 0) { DisplayErrorDialog("以下材质球没找到,请找何屹、唐蜜Check数据库文件\n", materialErrors); } EditorUtility.DisplayDialog("提示", string.Format("生成 {0} Prefab完成!", polygonType.ToString()), "确定"); }