Convert "MaterialInstanceConstant" to "MaterialInstanceDynamic" with Python. (or create MID)

I want to change Texture2D parameter in given MaterialInstance class with Python.

изображение

Code
new_material.set_texture_parameter_value("UnderwearMask",torso_mask)
Invokes with error

LogPython: Error: AttributeError: ‘MaterialInstanceConstant’ object has no attribute ‘set_texture_parameter_value’

class description
MaterialInstanceConstant

OK.
set_texture_parameter_value has “MaterialInstanceDynamic” class.

class description
MaterialInstanceDynamic

So, how i can convert “MaterialInstanceConstant” to “MaterialInstanceDynamic” with Python?

OR
How to create “MaterialInstanceDynamic” with Python? (There is no Factory for Dynamic instance creation. Only for constant unreal.MaterialInstanceConstantFactoryNew() )

Hello there!
I have the exact same problem, but it seems that changing MaterialInstanceConstant parameters is fine…

Here is how I do it:

material_editing_library = unreal.MaterialEditingLibrary
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
editor_asset_library = unreal.EditorAssetLibrary

mybaseMat= editor_asset_library.find_asset_data('/mypath/myMat')

materialInstance = asset_tools.create_asset('myInstance', '/myPath/', unreal.MaterialInstanceConstant, unreal.MaterialInstanceConstantFactoryNew())
material_editing_library.set_material_instance_scalar_parameter_value( materialInstance, 'myScalarParam', 42.0)
texAsset= editor_asset_library.find_asset_data('/mypath/myTex')
material_editing_library.set_material_instance_texture_parameter_value(materialInstance, 'myTexParam', texasset.get_asset())

Cheers!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.