Download

Importing material from a png/jpg file using python

I’m trying to automate the import of multiple png files to create materials that can be applied to meshes. When I import, the material created is completely black instead of the image I tried to load. I’ve also tried importing to texture (which creates a new texture completely fine) and then turn the texture to a material but still no avail. My code is below V.

path = ‘/Game/Textures’
file = ‘new_image2.png’
factory = unreal.MaterialFactoryNew()
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
asset_name = ‘new_image2_mat’

new_material = asset_tools.create_asset(asset_name, path, None, factory)

thanks in advance,
Matt.