ExportOBJ

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: == C# - ExportOBJ.cs == <csharp> using UnityEngine; using UnityEditor; using System.Collections; public class ObjExporter : ScriptableObject { private static Vector3 position; ...)
 
Line 1: Line 1:
 +
Author: DaveA
 +
 +
==Description==
 +
Allows you to export the currently selected mesh(es) to OBJ format. Simply wraps the Utility script(s) ObjExporter.cs (required). NOTE: For some reason only exports one selected object, although many may be selected. A little help here?
 +
 +
==Usage==
 +
You must place the script in a folder named '''Editor''' in your project's Assets folder for it to work properly.
 +
 +
Select an object in the scene heirarchy, then choose '''File -> Export -> Wavefront OBJ'''. The default name will be of the object selected (or first selected), but you can change it.
 +
 
== C# - ExportOBJ.cs ==
 
== C# - ExportOBJ.cs ==
  

Revision as of 23:09, 8 June 2010

Author: DaveA

Description

Allows you to export the currently selected mesh(es) to OBJ format. Simply wraps the Utility script(s) ObjExporter.cs (required). NOTE: For some reason only exports one selected object, although many may be selected. A little help here?

Usage

You must place the script in a folder named Editor in your project's Assets folder for it to work properly.

Select an object in the scene heirarchy, then choose File -> Export -> Wavefront OBJ. The default name will be of the object selected (or first selected), but you can change it.

C# - ExportOBJ.cs

<csharp> using UnityEngine; using UnityEditor; using System.Collections;

public class ObjExporter : ScriptableObject {

       private static Vector3 position;
       private static Quaternion rotation;
       private static Vector3 scale;
       private static string myName;
  
   [MenuItem ("File/Export/Wavefront OBJ")]
   static void DoExport()
   {

string meshName = Selection.gameObjects[0].name;

       string fileName = EditorUtility.SaveFilePanel("Export .obj file", "", meshName, "obj");

foreach (GameObject o in Selection.gameObjects) { MeshFilter mf = o.GetComponent(typeof(MeshFilter)) as MeshFilter; ObjExporterScript.MeshToFile(mf, fileName, false); }

   }

} </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox