I’m just unsure of where to go once I get a static mesh. My snippet only works in some cases where I imported the materials with the fbx.
import unreal
@unreal.uclass()
class MyEditorUtility(unreal.GlobalEditorUtilityBase):
pass
editor_util = MyEditorUtility()
editor_util.get_selected_assets()
for item in editor_util.get_selected_assets():
materialSlot=]
slotCount=10 # this is arbitrary, I don't know how to get total slots on a static mesh.
for i in range(slotCount):
try:
print 'index: %s slotname: %s' % (i, item.get_material(i).get_name())
materialSlot.append(item.get_material(i).get_name())
except:
break
editor_util.select_nothing
I believe what I was doing in a similar situation was to call get_material of the static mesh in a while loop as long as the get_material() returned a material (i.e. not None). This way I was counting the material slots until get_material ()returned None in which case I knew there are no more material slots.
I am not sure if my approach works with fbx that were imported without materials, though.
Out of interest: Could you share the snippet of how you import an fbx without material?
I’ve given up on UE python for now. If you look at AlexQuevillon posts and youtube channel, you will find a snippet to disable the option of importing materials,
FYI:
I am using the FbxSceneImportFactory to import an FBX into level and I was wondering if I could disable material import for this approach as well as you showed with yours.