private void OnGUI() { source = (TextureExporter.Source)EditorGUILayout.EnumPopup("Source", source); if (source == TextureExporter.Source.FromMeshFilter) { targetMeshFilter = EditorGUILayout.ObjectField("Target", targetMeshFilter, typeof(MeshFilter), true) as MeshFilter; } else { targetMesh = EditorGUILayout.ObjectField("Target", targetMesh, typeof(Mesh), true) as Mesh; } fileName = EditorGUILayout.TextField("File name", fileName); size = EditorGUILayout.IntPopup("Size", size, TextureExporter.textureSizeName, TextureExporter.textureSize); fileType = (ImageFileType)EditorGUILayout.EnumPopup("File type", fileType); textureType = (TextureExporter.TextureType)EditorGUILayout.EnumPopup("Texture type", textureType); EditorCommon.BrowseFolder("Path", ref path); GUI.enabled = CanSave(); if (EditorCommon.RightAnchoredButton("Save")) { bool willSave = false; string fullName = string.Format("{0}{1}", fileName, TextureExporter.GetExtension(fileType)); string fullPath = Path.Combine(path, fullName); if (System.IO.File.Exists(fullPath)) { if (EditorUtility.DisplayDialog( "File existed", "The file at specified path is already existed.\nWould you like to overwrite it?", "Yes", "No")) { willSave = true; } } else { willSave = true; } if (willSave) { if (source == TextureExporter.Source.FromMeshFilter) { TextureExporter.Export(targetMeshFilter, path, fileName, size, fileType, textureType); } else { TextureExporter.Export(targetMesh, path, fileName, size, fileType, textureType); } } } GUI.enabled = true; }
private void OnGUI() { EditorGUILayout.LabelField("Prefab", prefab.name); fileName = EditorGUILayout.TextField("File name", fileName); spread = EditorGUILayout.IntSlider("Spread", spread, 1, 100); size = EditorGUILayout.IntPopup("Size", size, TextureExporter.textureSizeName, TextureExporter.textureSize); fileType = (ImageFileType)EditorGUILayout.EnumPopup("File type", fileType); EditorCommon.BrowseFolder("Path", ref path); GUI.enabled = CanSave(); if (EditorCommon.RightAnchoredButton("Export")) { bool willSave = false; string fullName = string.Format("{0}{1}", fileName, TextureExporter.GetExtension(fileType)); string fullPath = Path.Combine(path, fullName); if (System.IO.File.Exists(fullPath)) { if (EditorUtility.DisplayDialog( "File existed", "The file at specified path is already existed.\nWould you like to overwrite it?", "Yes", "No")) { willSave = true; } } else { willSave = true; } if (willSave) { Save(); } } GUI.enabled = true; }
private void OnGUI() { target = EditorGUILayout.ObjectField("Target", target, typeof(MeshFilter), true) as MeshFilter; meshName = EditorGUILayout.TextField("Mesh name", meshName); fileType = (MeshSaver.FileType)EditorGUILayout.EnumPopup("File type", fileType); EditorCommon.BrowseFolder("Path", ref path); GUI.enabled = target != null && target.sharedMesh != null && !string.IsNullOrEmpty(meshName) && !string.IsNullOrEmpty(path); if (EditorCommon.RightAnchoredButton("Save")) { Material mat = null; MeshRenderer mr = target.GetComponent <MeshRenderer>(); if (mr != null) { mat = mr.sharedMaterial; } MeshSaver.Save(target.sharedMesh, mat, path, meshName, fileType); } GUI.enabled = true; }