I have some problem with my blender code export to fbx file. I set color by vertex_color and set mode is Vertex_paint. But when I export this object to fbx file and open in Unity it is not include color. I think the reason might be dont set color for material of object. So could you help me to convert ? This is my code. Thank you so much for your help

import math

# mesh arrays
verts = []
faces = []

# mesh variables
numX = 10
numY = 10

# wave variables
freq = 1
amp = 1
scale = 1

#fill verts array
for i in range (0, numX):
    for j in range(0,numY):
        x = scale * i
        y = scale * j
        z = scale*((amp*math.cos(i*freq))+(amp*math.sin(j*freq)))
        vert = (x,y,z) 

#fill faces array
count = 0
for i in range (0, numY *(numX-1)):
    if count < numY-1:
        A = i
        B = i+1
        C = (i+numY)+1
        D = (i+numY)
        face = (A,B,C,D)
        count = count + 1
        count = 0

#create mesh and object
mesh = bpy.data.meshes.new("wave")
object = bpy.data.objects.new("wave",mesh)
#set mesh location
object.location = bpy.context.scene.cursor.location

#create mesh from python data

vert_list = mesh.vertices
color_map_collection = mesh.vertex_colors
if len(color_map_collection) == 0:

color_map = color_map_collection['Col']
i = 0

for poly in mesh.polygons:
    for idx in poly.loop_indices:
        loop = mesh.loops[idx]
        v = loop.vertex_index
        final = (0.1,0.5,0.2,1)
        color_map.data[i].color = final     
        i += 1

bpy.context.view_layer.objects.active = object
bpy.ops.object.mode_set(mode='VERTEX_PAINT', toggle=False)
  • $\begingroup$ Do the colors look like you'd expect in blender? Unity doesn't read vertex color by default, you have to enable it. Also when you build, you need to enable vertex color under the mesh optmization options. Other than that I never had troubles with vertex color and fbx. $\endgroup$ – Frederik Steinmetz Apr 8 at 8:30
  • $\begingroup$ HI @FrederikSteinmetz absolutely, I would like to make the color look like blender in Unity. Thank you for your reply. Btw if you have any document or example about how to enable vertex color under the mesh optimization options in blender/ even Unity, please share for me. Honestly, I pretty fresh in this field. Thank you $\endgroup$ – Phong Nguyễn Apr 8 at 9:17
  • $\begingroup$ before I do this, do you have a shader that handles vert. col. in Unity? $\endgroup$ – Frederik Steinmetz Apr 8 at 10:29
  • $\begingroup$ Your mean is vertex and faces define? Sorry for my silly question. Because I am not clearly understand "shader". $\endgroup$ – Phong Nguyễn Apr 8 at 10:32
  • $\begingroup$ You won't see any vertex colors in Unity, unless you have a shader (material) that can read them. $\endgroup$ – Frederik Steinmetz Apr 8 at 10:38

Unity is a game engine, not a vertex editing engine. While you can build or download tools to edit meshes inside of Unity, I'd advise you to stick to Blender for that. Unity displays everything similar to Eevee. If you assign a default material to an object in Eevee it also won't show vertex colors, unless you tell your material to read them. In Blender, you need a built-in node for that, in Unity you need a shader that can read and display them.
Unity will also omit any vertex color information in the build, unless you tell it to keep them.
enter image description here
This option is in the Player Settings.

| improve this answer | |
  • $\begingroup$ Thank you for your support, I actually import fbx within color into Unity $\endgroup$ – Phong Nguyễn Apr 9 at 3:48
  • $\begingroup$ if it helped yout, would you mind accepting my answer? $\endgroup$ – Frederik Steinmetz Apr 9 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.