public void Export() { string meshName = gameObject.name; string fileName = EditorUtility.SaveFilePanel("Export .obj file", "", meshName, "obj"); ObjExporterScript.Start(); StringBuilder meshString = new StringBuilder(); meshString.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); Transform t = gameObject.transform; Vector3 originalPosition = t.position; t.position = Vector3.zero; meshString.Append(processTransform(t, false)); WriteToFile(meshString.ToString(), fileName); t.position = originalPosition; ObjExporterScript.End(); Debug.Log("Exported Mesh: " + fileName); }
public static void DoExportFromGame(GameObject[] saves) { string meshName = saves[0].tag; string fileName = meshName + ".obj"; bool makeSubmeshes = false; ObjExporterScript.Start(); StringBuilder meshString = new StringBuilder(); meshString.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); Transform t = saves[0].transform; Vector3 originalPosition = t.position; t.position = Vector3.zero; if (!makeSubmeshes) { meshString.Append("g ").Append(t.name).Append("\n"); } meshString.Append(ProcessTransform(t, makeSubmeshes)); WriteToFile(meshString.ToString(), fileName); t.position = originalPosition; ObjExporterScript.End(); Debug.Log("Exported Mesh: " + fileName); }
static void DoExport() { if (Selection.gameObjects.Length == 0) { Debug.Log("Didn't Export Any Meshes; Nothing was selected!"); return; } Transform t = Selection.gameObjects[0].transform; MeshFilter mf = t.GetComponent <MeshFilter>(); if (null == mf) { EditorUtility.DisplayDialog("title", "没有选择mesh", "ok"); return; } string meshName = Selection.gameObjects[0].name; string fileName = EditorUtility.SaveFilePanel("Export .obj file", "", meshName, "obj"); ObjExporterScript.Start(); StringBuilder meshString = new StringBuilder(); meshString.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); Vector3 originalPosition = t.position; t.position = Vector3.zero; if (mf) { meshString.Append(ObjExporterScript.MeshToString(mf, t)); } WriteToFile(meshString.ToString(), fileName); t.position = originalPosition; ObjExporterScript.End(); Debug.Log("Exported Mesh: " + fileName); }
public void ExportChakraMesh(ChakraPosition cp, Mesh m) { ObjExporterScript ex = new ObjExporterScript(); ObjExporterScript.Start(); string str = ObjExporterScript.MeshToString(m, this.transform, null); int index = this.ChakraIndex(cp); string toPath = (Application.dataPath + "/ExportedMeshes/ChakraMesh_" + (index + 1) + "_" + cp.name.Trim().Replace(" ", "_") + ".obj"); Debug.Log("Saving mesh to: " + toPath); StreamWriter sw = new StreamWriter(toPath); sw.Write(str); sw.Close(); }
public static void DoExport(GameObject gameObject, bool makeSubmeshes) { string meshName = gameObject.name.Replace(':', '_'); string fileName = "C:\\Users\\st_dg\\OneDrive\\TLD\\exported-meshes\\" + meshName + ".obj"; Debug.Log("Exporting " + fileName); ObjExporterScript.Start(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); Transform t = gameObject.transform; Transform originalParent = gameObject.transform.parent; Vector3 originalLocalPosition = t.localPosition; Quaternion originalLocalRotation = t.localRotation; Vector3 originalLocalScale = t.localScale; t.parent = null; t.position = Vector3.zero; t.localScale = Vector3.one; t.localRotation = Quaternion.identity; if (!makeSubmeshes) { stringBuilder.Append("g ").Append(t.name).Append("\n"); } stringBuilder.Append(processTransform(t, makeSubmeshes)); WriteToFile(stringBuilder.ToString(), fileName); t.parent = originalParent; t.localPosition = originalLocalPosition; t.localRotation = originalLocalRotation; t.localScale = originalLocalScale; ObjExporterScript.End(); Debug.Log("Exported Mesh: " + fileName); }
static void DoExport(bool makeSubmeshes) { if (Selection.gameObjects.Length == 0) { Debug.Log("Didn't Export Any Meshes; Nothing was selected!"); return; } string meshName = Selection.gameObjects[0].name; string fileName = EditorUtility.SaveFilePanel("Export .obj file", "", meshName, "obj"); ObjExporterScript.Start(); StringBuilder meshString = new StringBuilder(); meshString.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); Transform t = Selection.gameObjects[0].transform; Vector3 originalPosition = t.position; t.position = Vector3.zero; if (!makeSubmeshes) { meshString.Append("g ").Append(t.name).Append("\n"); } string meshDataStr = ""; meshString.Append(processTransform(t, makeSubmeshes, ref meshDataStr)); WriteToFile(meshString.ToString(), fileName); t.position = originalPosition; ObjExporterScript.End(); Debug.Log("Exported Mesh: " + fileName); }
static public void DoExport(GameObject obj, bool makeSubmeshes, string navType) { if (obj == null) { Debug.Log("Didn't Export Any Meshes; Nothing was selected!"); return; } string meshName = obj.name; string fileName = "Exports/MapGen." + navType + ".obj"; ObjExporterScript.Start(); StringBuilder meshString = new StringBuilder(); meshString.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); Transform t = obj.transform; Vector3 originalPosition = t.position; t.position = Vector3.zero; if (!makeSubmeshes) { meshString.Append("g ").Append(t.name).Append("\n"); } meshString.Append(processTransform(t, makeSubmeshes)); WriteToFile(meshString.ToString(), fileName); t.position = originalPosition; ObjExporterScript.End(); Debug.Log("Exported Mesh: " + fileName); }
public static void DoExport(bool makeSubmeshes, GameObject objToExport, string path) { if (objToExport == null) { Debug.Log("No object to export!"); return; } string meshName = GenerateMeshName(); string fileName = GenerateFileName(meshName, path); ObjExporterScript.Start(); StringBuilder meshString = new StringBuilder(); meshString.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); Transform t = objToExport.transform; Vector3 originalPosition = t.position; t.position = Vector3.zero; if (!makeSubmeshes) { meshString.Append("g ").Append(t.name).Append("\n"); } meshString.Append(processTransform(t, makeSubmeshes)); WriteToFile(meshString.ToString(), fileName); t.position = originalPosition; ObjExporterScript.End(); Debug.Log("Exported Mesh: " + fileName); }
public static void DoExport(GameObject[] selections) { if (selections.Length == 0) { Debug.Log("Didn't Export Any Meshes; Nothing was selected!"); return; } string meshName = selections[0].name; string fileName = EditorUtility.SaveFilePanel("Export .obj file", "", meshName, "obj"); ObjExporterScript.Start(); StringBuilder meshString = new StringBuilder(); meshString.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); foreach (GameObject go in selections) { Transform t = go.transform; Vector3 originalPosition = t.position; t.position = Vector3.zero; meshString.Append(processTransform(t)); WriteToFile(meshString.ToString(), fileName); t.position = originalPosition; } ObjExporterScript.End(); Debug.Log("Exported Mesh: " + fileName); }
public static void Export(GameObject export) { string meshName = export.name; string fileName = OpenFilePanel.Open(); if (!string.IsNullOrEmpty(fileName)) { ObjExporterScript.Start(); StringBuilder meshString = new StringBuilder(); meshString.Append("#" + meshName + ".obj" + "\n#" + System.DateTime.Now.ToLongDateString() + "\n#" + System.DateTime.Now.ToLongTimeString() + "\n#-------" + "\n\n"); Transform t = export.transform; Vector3 originalPosition = t.position; t.position = Vector3.zero; meshString.Append("g ").Append(t.name).Append("\n"); meshString.Append(processTransform(t)); WriteToFile(meshString.ToString(), fileName); t.position = originalPosition; ObjExporterScript.End(); Debug.Log("Exported Cloud: " + fileName); } }