private void reset() { // Meshes mGlobalScale = 1.0f; mMeshCompression = ModelImporterMeshCompression.Off; mOptimizeMesh = false; mAddCollider = false; mSwapUVChannels = false; mGenerateSecondaryUV = false; // Normals & Tangents mNormalImportMode = ModelImporterTangentSpaceMode.Import; mTangentImportMode = ModelImporterTangentSpaceMode.Calculate; mNormalSmoothingAngle = 60.0f; mSplitTangentsAcrossSeams = false; // Materials mImportMaterials = true; mMaterialName = ModelImporterMaterialName.BasedOnTextureName; mMaterialSearch = ModelImporterMaterialSearch.RecursiveUp; // remember current preset selection mCurrentPresetName = mDefaultPresetName; EditorPrefs.SetString( "ModelImportManager.CurrentPreset", mCurrentPresetName ); }
private void AnalyzerModel() { GameObject asset = AssetDatabase.LoadMainAssetAtPath(path) as GameObject; this.name = asset.name; this.scale = mi.globalScale; this.meshCompression = mi.meshCompression; this.isRW = mi.isReadable; this.isAddCollider = mi.addCollider; this.swapUVChannels = mi.swapUVChannels; this.normalImportMode = mi.normalImportMode; this.tangentImportMode = mi.tangentImportMode; this.isBakeIK = mi.bakeIK; this.animCompression = mi.animationCompression; if (!mi.importAnimation || mi.animationType == ModelImporterAnimationType.None) { this.animationClipCount = 0; } else { this.animationClipCount = mi.clipAnimations.Length; } CollectMeshInfo(asset); CheckValid(); }
private void loadPreset( string presetName ) { string prefix = "ModelImportManager." + presetName; // Meshes mGlobalScale = EditorPrefs.GetFloat( prefix + ".GlobalScale", 1.0f ); mMeshCompression = (ModelImporterMeshCompression)System.Enum.Parse( typeof(ModelImporterMeshCompression), EditorPrefs.GetString( prefix + ".MeshCompression", "Off" ) ); mOptimizeMesh = EditorPrefs.GetBool( prefix + ".OptimizeMesh", false ); mAddCollider = EditorPrefs.GetBool( prefix + ".AddCollider", false ); mSwapUVChannels = EditorPrefs.GetBool( prefix + ".SwapUVChannels", false ); mGenerateSecondaryUV = EditorPrefs.GetBool( prefix + ".GenerateSecondaryUV", false ); // Normals & Tangents mNormalImportMode = (ModelImporterTangentSpaceMode)System.Enum.Parse( typeof(ModelImporterTangentSpaceMode), EditorPrefs.GetString( prefix + ".NormalImportMode", "Import" ) ); mTangentImportMode = (ModelImporterTangentSpaceMode)System.Enum.Parse( typeof(ModelImporterTangentSpaceMode), EditorPrefs.GetString( prefix + ".TangentImportMode", "Calculate" ) ); mNormalSmoothingAngle = EditorPrefs.GetFloat( prefix + ".NormalSmoothingAngle", 60.0f ); mSplitTangentsAcrossSeams = EditorPrefs.GetBool( prefix + ".SplitTangentsAcrossSeams", false ); // Materials mImportMaterials = EditorPrefs.GetBool( prefix + ".ImportMaterials", false ); mMaterialName = (ModelImporterMaterialName)System.Enum.Parse( typeof(ModelImporterMaterialName), EditorPrefs.GetString( prefix + ".MaterialName", "BasedOnTextureName" ) ); mMaterialSearch = (ModelImporterMaterialSearch)System.Enum.Parse( typeof(ModelImporterMaterialSearch), EditorPrefs.GetString( prefix + ".MaterialSearch", "RecursiveUp" ) ); // remember current preset selection mCurrentPresetName = presetName; EditorPrefs.SetString( "ModelImportManager.CurrentPreset", mCurrentPresetName ); }
public MeshData(string path, ModelImporterTangentSpaceMode normaltype, ModelImporterMeshCompression meshcompress, bool optmesh, bool readable) { MeshPath = path; NormalImportMode = normaltype; OptimizeMesh = optmesh; IsReadable = readable; MeshCompression = meshcompress; }
public Styles() { this.TangentSpaceModeOptLabelsAll = new GUIContent[] { this.TangentSpaceOptionImport, this.TangentSpaceOptionCalculate, this.TangentSpaceOptionNone }; this.TangentSpaceModeOptLabelsCalculate = new GUIContent[] { this.TangentSpaceOptionCalculate, this.TangentSpaceOptionNone }; this.TangentSpaceModeOptLabelsNone = new GUIContent[] { this.TangentSpaceOptionNone }; ModelImporterTangentSpaceMode[] modeArray1 = new ModelImporterTangentSpaceMode[3]; modeArray1[1] = ModelImporterTangentSpaceMode.Calculate; modeArray1[2] = ModelImporterTangentSpaceMode.None; this.TangentSpaceModeOptEnumsAll = modeArray1; this.TangentSpaceModeOptEnumsCalculate = new ModelImporterTangentSpaceMode[] { ModelImporterTangentSpaceMode.Calculate, ModelImporterTangentSpaceMode.None }; this.TangentSpaceModeOptEnumsNone = new ModelImporterTangentSpaceMode[] { ModelImporterTangentSpaceMode.None }; }
public MeshImportSettings() { globalScale = 1.0f; addCollider = false; normalSmoothingAngle = 60.0f; splitTangentsAcrossSeams = true; swapUVChannels = false; generateSecondaryUV = false; optimizeMesh = false; normalImportMode = ModelImporterTangentSpaceMode.Import; tangentImportMode = ModelImporterTangentSpaceMode.Calculate; meshCompression = ModelImporterMeshCompression.Off; }
private void drawSettingDialog() { GUILayout.BeginVertical( GUILayout.MinWidth( 300 ), GUILayout.MaxWidth( 1000 ), GUILayout.ExpandWidth( true ) ); GUILayout.Label( "Meshes", EditorStyles.boldLabel ); // Global scale factor for importing. mGlobalScale = EditorGUILayout.FloatField( "Scale Factor", mGlobalScale ); // Mesh compression setting. mMeshCompression = (ModelImporterMeshCompression)EditorGUILayout.EnumPopup( "Mesh Compression", mMeshCompression ); // Vertex optimization setting mOptimizeMesh = EditorGUILayout.Toggle( "Optimize Mesh", mOptimizeMesh ); // Add mesh colliders to imported meshes. mAddCollider = EditorGUILayout.Toggle( "Generate Colliders", mAddCollider ); // Swap primary and secondary UV channels when importing. mSwapUVChannels = EditorGUILayout.Toggle( "Swap UVs", mSwapUVChannels ); // Generate secondary UV set for lightmapping. mGenerateSecondaryUV = EditorGUILayout.Toggle( "Generate Lightmap UVs", mGenerateSecondaryUV ); EditorGUILayout.Space(); GUILayout.Label( "Normals & Tangents", EditorStyles.boldLabel ); // Normals import mode. mNormalImportMode = (ModelImporterTangentSpaceMode)EditorGUILayout.EnumPopup( "Normals", mNormalImportMode ); // Tangents import mode. mTangentImportMode = (ModelImporterTangentSpaceMode)EditorGUILayout.EnumPopup( "Tangents", mTangentImportMode ); EditorGUI.BeginDisabledGroup( mNormalImportMode != ModelImporterTangentSpaceMode.Calculate ); // Smoothing angle for calculating normals. mNormalSmoothingAngle = (int)EditorGUILayout.IntSlider( "Smoothing Angle", (int)mNormalSmoothingAngle, 0, 180 ); EditorGUI.EndDisabledGroup(); // Should tangents be split across UV seams. mSplitTangentsAcrossSeams = EditorGUILayout.Toggle( "Split Tangents", mSplitTangentsAcrossSeams ); EditorGUILayout.Space(); GUILayout.Label( "Materials", EditorStyles.boldLabel ); // Import materials from file. mImportMaterials = EditorGUILayout.Toggle( "Import Materials", mImportMaterials ); EditorGUI.BeginDisabledGroup( !mImportMaterials ); // Material naming setting. mMaterialName = (ModelImporterMaterialName)EditorGUILayout.EnumPopup( "Material Naming", mMaterialName ); // Existing material search setting. mMaterialSearch = (ModelImporterMaterialSearch)EditorGUILayout.EnumPopup( "Material Search", mMaterialSearch ); EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if( mCurrentPresetName != mDefaultPresetName ) { if( GUILayout.Button( "Save" ) ) savePreset( mCurrentPresetName ); if( GUILayout.Button( "Delete" ) ) deletePreset( mCurrentPresetName ); } else { if( GUILayout.Button( "Save As", GUILayout.Width( 200 ) ) && ( mNewPresetName.Length > 0 ) && ( mNewPresetName != mDefaultPresetName ) ) { savePreset( mNewPresetName ); loadPreset( mNewPresetName ); } // only characters allowed mNewPresetName = Regex.Replace( GUILayout.TextField( mNewPresetName ), @"[^\w]", string.Empty ); } EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); }
public void OnGUI() { EditorGUILayout.LabelField("要检测的文件夹:"); m_TargetDirectory = EditorGUILayout.TextField(m_TargetDirectory); GUI.SetNextControlName("Browse"); if (GUILayout.Button("Browse", GUILayout.Width(60f))) { string pathTarget = EditorUtility.OpenFolderPanel("Open Target Directory", m_TargetDirectory, ""); m_TargetDirectory = pathTarget.Length > 0 ? pathTarget : m_TargetDirectory; GUI.FocusControl("Browse"); } EditorGUILayout.Space(); EditorGUILayout.Space(); checkType = (CheckType)GUILayout.Toolbar((int)checkType, checkTypeLabel); if (checkType == CheckType.TEXTURE) { EditorGUILayout.HelpBox("支持文件名后缀为 PSD、JPG、PNG、TGA", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); GUILayout.Label("图片幂指数检索:", GUILayout.Width(80f), GUILayout.Height(30f)); is_Mizhi = EditorGUILayout.Toggle(is_Mizhi, GUILayout.Width(40f), GUILayout.Height(30f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("宽高不相等检索:", GUILayout.Width(80f), GUILayout.Height(30f)); is_WidHei = EditorGUILayout.Toggle(is_WidHei, GUILayout.Width(40f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_Width = EditorGUILayout.Toggle(is_Width, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("图片宽检索:", GUILayout.Width(80f), GUILayout.Height(30f)); widthWarning = EditorGUILayout.IntField("宽度像素(警告):", widthWarning); widthErroring = EditorGUILayout.IntField("宽度像素(错误):", widthErroring); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_Height = EditorGUILayout.Toggle(is_Height, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("图片高检索:", GUILayout.Width(80f), GUILayout.Height(30f)); heightWarning = EditorGUILayout.IntField("高度像素(警告):", heightWarning); heightErroring = EditorGUILayout.IntField("高度像素(错误):", heightErroring); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.VERTEX_AND_FACE) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_Vertex = EditorGUILayout.Toggle(is_Vertex, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("模型顶点检索:", GUILayout.Width(80f), GUILayout.Height(30f)); vertexWarning = EditorGUILayout.IntField("顶点数(警告):", vertexWarning); vertexErroring = EditorGUILayout.IntField("顶点数(错误):", vertexErroring); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_face = EditorGUILayout.Toggle(is_face, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("模型面检索:", GUILayout.Width(80f), GUILayout.Height(30f)); faceWarning = EditorGUILayout.IntField("面数(警告):", faceWarning); faceErroring = EditorGUILayout.IntField("面数(错误):", faceErroring); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.TANGENT) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_set_tangent = EditorGUILayout.Toggle("修改为:", is_set_tangent); modelTangentOption = (ModelImporterTangentSpaceMode)EditorGUILayout.EnumPopup(modelTangentOption); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.BONE_AMOUNT) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); ignoreZeroBone = EditorGUILayout.Toggle("忽略0骨骼", ignoreZeroBone); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.BONE_QUALITY) { EditorGUILayout.HelpBox("检测 Prefab", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_set_boneQuality = EditorGUILayout.Toggle("修改为:", is_set_boneQuality); boneQuality = (SkinQuality)EditorGUILayout.EnumPopup(boneQuality); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Go", GUILayout.Width(80f), GUILayout.Height(30f))) { if (allFiles == null) { try { if (m_TargetDirectory == "") { string str = "设置要检测的文件夹"; GUIContent content = new GUIContent(str); window.ShowNotification(content); } if (m_TargetDirectory != "") { allFiles = new List<FileInfo>(); GetAllFiles(new DirectoryInfo(m_TargetDirectory)); progressTotal = allFiles.Count; progressCurrent = 0; meshInfo.Clear(); meshInfoNoSort.Clear(); pictureInfo.Clear(); PictureRedWid.Clear(); PictureGreenWid.Clear(); PictureYellowWid.Clear(); PictureRedHei.Clear(); PictureGreenHei.Clear(); PictureYellowHei.Clear(); PictureWidHei.Clear(); ModelMeshRedVer.Clear(); ModelMeshGreenVer.Clear(); ModelMeshYellowVer.Clear(); ModelMeshRedFac.Clear(); ModelMeshGreenFac.Clear(); ModelMeshYellowFac.Clear(); ModelTangentMsg.Clear(); ModelBoneMsg.Clear(); BoneQualityMsg.Clear(); } } catch (Exception e) { Debug.LogError(e.Message); Debug.LogError(e.StackTrace); } } } EditorGUILayout.EndHorizontal(); { float progressValue = progressTotal == 0 ? 0 : (float)progressCurrent / (float)progressTotal; EditorGUI.ProgressBar(new Rect(5, position.height - 22, position.width - 10, 20), progressValue, progressCurrent + "/" + progressTotal); } if (allFiles != null) { if (allFiles.Count > 0) { if (progressCount >= 1) { progressCount = -1; ProgressCoroutine(); } ++progressCount; this.Repaint(); } else { allFiles = null; m_RootDirectory = Application.persistentDataPath; string resultPath = m_RootDirectory + htmlstr; ConstructOutput(); ConstructHTML(); UnityEditor.EditorUtility.OpenWithDefaultApp(resultPath); } } }
/// <inherit/> public override void OnGUI() { // meshes EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel); scaleFactor = EditorGUILayout.FloatField("Scale Factor", scaleFactor); meshCompression = (ModelImporterMeshCompression)EditorGUILayout.EnumPopup("Mesh Compression", meshCompression); readWriteEnabled = EditorGUILayout.Toggle("Read/Write Enabled", readWriteEnabled); optimizeMesh = EditorGUILayout.Toggle("Optimize Mesh", optimizeMesh); importBlendShapes = EditorGUILayout.Toggle("Import BlendShapes", importBlendShapes); generateColliders = EditorGUILayout.Toggle("Generate Colliders", generateColliders); swapUVs = EditorGUILayout.Toggle("Swap UVs", swapUVs); generateLightmapUV = EditorGUILayout.Toggle("Generate Lightmap UVs", generateLightmapUV); // normals and tangents EditorGUILayout.LabelField("Normals & Tangents", EditorStyles.boldLabel); normals = (ModelImporterTangentSpaceMode)EditorGUILayout.EnumPopup("Normals", normals); tangents = (ModelImporterTangentSpaceMode)EditorGUILayout.EnumPopup("Tangents", tangents); GUI.enabled = normals == ModelImporterTangentSpaceMode.Calculate; smoothingAngle = EditorGUILayout.Slider("Smoothing Angle", smoothingAngle, SmoothingAngleMin, SmoothingAngleMax); GUI.enabled = true; GUI.enabled = tangents == ModelImporterTangentSpaceMode.None; splitTangents = EditorGUILayout.Toggle("Split Tangents", splitTangents); GUI.enabled = true; // materials EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel); importMaterials = EditorGUILayout.Toggle("Import Materials", importMaterials); if (importMaterials) { materialNaming = (ModelImporterMaterialName)EditorGUILayout.EnumPopup("Material Naming", materialNaming); materialSearch = (ModelImporterMaterialSearch)EditorGUILayout.EnumPopup("Material Search", materialSearch); } }
public void OnGUI() { EditorGUILayout.LabelField("要检测的文件夹:"); m_TargetDirectory = EditorGUILayout.TextField(m_TargetDirectory); GUI.SetNextControlName("Browse"); if (GUILayout.Button("Browse", GUILayout.Width(60f))) { string pathTarget = EditorUtility.OpenFolderPanel("Open Target Directory", m_TargetDirectory, ""); m_TargetDirectory = pathTarget.Length > 0 ? pathTarget : m_TargetDirectory; GUI.FocusControl("Browse"); } EditorGUILayout.Space(); EditorGUILayout.Space(); checkType = (CheckType)GUILayout.Toolbar((int)checkType, checkTypeLabel); if (checkType == CheckType.TEXTURE) { EditorGUILayout.HelpBox("支持文件名后缀为 PSD、JPG、PNG、TGA", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); GUILayout.Label("图片幂指数检索:", GUILayout.Width(80f), GUILayout.Height(30f)); is_Mizhi = EditorGUILayout.Toggle(is_Mizhi, GUILayout.Width(40f), GUILayout.Height(30f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("宽高不相等检索:", GUILayout.Width(80f), GUILayout.Height(30f)); is_WidHei = EditorGUILayout.Toggle(is_WidHei, GUILayout.Width(40f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_Width = EditorGUILayout.Toggle(is_Width, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("图片宽检索:", GUILayout.Width(80f), GUILayout.Height(30f)); widthWarning = EditorGUILayout.IntField("宽度像素(警告):", widthWarning); widthErroring = EditorGUILayout.IntField("宽度像素(错误):", widthErroring); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_Height = EditorGUILayout.Toggle(is_Height, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("图片高检索:", GUILayout.Width(80f), GUILayout.Height(30f)); heightWarning = EditorGUILayout.IntField("高度像素(警告):", heightWarning); heightErroring = EditorGUILayout.IntField("高度像素(错误):", heightErroring); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.VERTEX_AND_FACE) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_Vertex = EditorGUILayout.Toggle(is_Vertex, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("模型顶点检索:", GUILayout.Width(80f), GUILayout.Height(30f)); vertexWarning = EditorGUILayout.IntField("顶点数(警告):", vertexWarning); vertexErroring = EditorGUILayout.IntField("顶点数(错误):", vertexErroring); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); is_face = EditorGUILayout.Toggle(is_face, GUILayout.Width(40f), GUILayout.Height(30f)); GUILayout.Label("模型面检索:", GUILayout.Width(80f), GUILayout.Height(30f)); faceWarning = EditorGUILayout.IntField("面数(警告):", faceWarning); faceErroring = EditorGUILayout.IntField("面数(错误):", faceErroring); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.TANGENT) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_set_tangent = EditorGUILayout.Toggle("修改为:", is_set_tangent); modelTangentOption = (ModelImporterTangentSpaceMode)EditorGUILayout.EnumPopup(modelTangentOption); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.BONE_AMOUNT) { EditorGUILayout.HelpBox("支持文件名后缀为 FBX", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); ignoreZeroBone = EditorGUILayout.Toggle("忽略0骨骼", ignoreZeroBone); EditorGUILayout.EndHorizontal(); } if (checkType == CheckType.BONE_QUALITY) { EditorGUILayout.HelpBox("检测 Prefab", MessageType.Info, true); EditorGUILayout.BeginHorizontal(); is_set_boneQuality = EditorGUILayout.Toggle("修改为:", is_set_boneQuality); boneQuality = (SkinQuality)EditorGUILayout.EnumPopup(boneQuality); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Go", GUILayout.Width(80f), GUILayout.Height(30f))) { if (allFiles == null) { try { if (m_TargetDirectory == "") { string str = "设置要检测的文件夹"; GUIContent content = new GUIContent(str); window.ShowNotification(content); } if (m_TargetDirectory != "") { allFiles = new List <FileInfo>(); GetAllFiles(new DirectoryInfo(m_TargetDirectory)); progressTotal = allFiles.Count; progressCurrent = 0; meshInfo.Clear(); meshInfoNoSort.Clear(); pictureInfo.Clear(); PictureRedWid.Clear(); PictureGreenWid.Clear(); PictureYellowWid.Clear(); PictureRedHei.Clear(); PictureGreenHei.Clear(); PictureYellowHei.Clear(); PictureWidHei.Clear(); ModelMeshRedVer.Clear(); ModelMeshGreenVer.Clear(); ModelMeshYellowVer.Clear(); ModelMeshRedFac.Clear(); ModelMeshGreenFac.Clear(); ModelMeshYellowFac.Clear(); ModelTangentMsg.Clear(); ModelBoneMsg.Clear(); BoneQualityMsg.Clear(); } } catch (Exception e) { Debug.LogError(e.Message); Debug.LogError(e.StackTrace); } } } EditorGUILayout.EndHorizontal(); { float progressValue = progressTotal == 0 ? 0 : (float)progressCurrent / (float)progressTotal; EditorGUI.ProgressBar(new Rect(5, position.height - 22, position.width - 10, 20), progressValue, progressCurrent + "/" + progressTotal); } if (allFiles != null) { if (allFiles.Count > 0) { if (progressCount >= 1) { progressCount = -1; ProgressCoroutine(); } ++progressCount; this.Repaint(); } else { allFiles = null; m_RootDirectory = Application.persistentDataPath; string resultPath = m_RootDirectory + htmlstr; ConstructOutput(); ConstructHTML(); UnityEditor.EditorUtility.OpenWithDefaultApp(resultPath); } } }