Search code examples
importunity-game-engineassets.obj

.OBJ groups and Unity


I have an .OBJ file (which looks like this) and when I import the file into Unity (4.5.3f3) the second group (Square_Plane) does not import.

The .OBJ contains the following:

mtllib test.mtl
g Triangle_Plane.001
v -2.210575 0.000000 -0.986309
v -2.210575 0.000000 1.013691
v -4.210576 0.000000 1.013691
usemtl (null)
s off
f 1 3 2

g Square_Plane
v 1.000000 0.000000 -1.000000
v 1.000000 0.000000 1.000000
v -1.000000 0.000000 1.000000
v -1.000000 0.000000 -1.000000
usemtl (null)
s off
f 4 7 6 5

This is what it looks like outside of Unity: Should be: Then in Unity: Fail Have I done something wrong in my .OBJ file, or does anyone know if there is an import setting or similar for Unity which will fix this issue?


Solution

  • Your file defines a quad. Unity doesn't like quads. If you split it up in two triangles it works:

    mtllib test.mtl
    g Triangle_Plane.001
    v -2.210575 0.000000 -0.986309
    v -2.210575 0.000000 1.013691
    v -4.210576 0.000000 1.013691
    usemtl (null)
    s off
    f 1 3 2
    
    g Square_Plane
    v 1.000000 0.000000 -1.000000
    v 1.000000 0.000000 1.000000
    v -1.000000 0.000000 1.000000
    v -1.000000 0.000000 -1.000000
    usemtl (null)
    s off
    f 4 7 6
    f 4 6 5
    

    Obj succesfully imported in Unity