To import FBX into Unity and convert it to a mesh using C#, you should use the FBXImporter
class. The following code shows how to load an FBX file and access its mesh data:
main.cs955 chars33 lines
In this example, we load an FBX file from the specified path and access its mesh data by finding the mesh renderer component in the object hierarchy and getting the mesh filter component attached to it. We then access the mesh data from the mesh filter component and do something with it, in this case printing the number of vertices in the mesh.
Note that in order to use the FBXImporter
class, you need to have the Unity Editor installed and import the UnityEditor
namespace.
gistlibby LogSnag