public static void ConvertVBM() { //let user select vpp folder he would like to unpack string fileSearchMessage = "Select VBM file you would like to convert into a material."; string defaultPath = "Assets"; if (!string.IsNullOrEmpty(lastVBMPath)) { defaultPath = Path.GetDirectoryName(lastVBMPath); } string filePath = EditorUtility.OpenFilePanel(fileSearchMessage, defaultPath, "vbm"); if (string.IsNullOrEmpty(filePath)) { return; } if (!UFUtils.IsAssetPath(filePath)) { Debug.LogError("Can only convert files that are in an Asset folder. " + "Please move the file into your Unity project and try again."); return; } lastVBMPath = filePath; VBMReader reader = new VBMReader(filePath); reader.MakeMaterialAtAssetPath(); }
private static void ExportFile(string name, string exportFolder, byte[] bytes, int start, int length) { string ext = ""; Byte[] fileBytes = new Byte[length]; for (int i = 0; i < length; i++) { fileBytes[i] = bytes[start + i]; } string exportPath = exportFolder + '/' + name; try { File.WriteAllBytes(exportPath, fileBytes); ext = Path.GetExtension(name).TrimStart('.').ToLower(); } catch (Exception e) { Debug.LogError("Failed to write to " + name + " Because of error: \n" + e); } //handle extentions that require further processing switch (ext) { case "v3d": case "v3m": case "v3c": V3DReader modelReader = new V3DReader(exportPath); modelReader.MakePrefabAtAssetPath(); break; case "vbm": VBMReader texReader = new VBMReader(exportPath); texReader.MakeMaterialAtAssetPath(); break; case "wav": new WavRepairer(exportPath); break; } }