I’ve tried so many variations of the path that I’ve given up. Is there a way to just wildcard this so TL1_Wall_Tile gets replaced with Ceramic_Enamel_Tiles_MAT?
ive attempted the above, but im receiving the following messages. please can someone help!
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import unreal
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
ModuleNotFoundError: No module named ‘unreal’
>>>
>>> def replace_material(original, replacement):
… original_asset = unreal.EditorAssetLibrary.load_asset(original)
… replacement_asset = unreal.EditorAssetLibrary.load_asset(replacement)
… unreal.EditorAssetLibrary.consolidate_assets(replacement_asset, [original_asset])
…
>>> replace_material(“/Game/Content/Materials/Metals_-Steel-_RSA_S355J”, “/Game/Content/Materials/M_Metal_Steel”)
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “<stdin>”, line 2, in replace_material
NameError: name ‘unreal’ is not defined
>>>
Have you set Unreal’s built-in Python version to 3.X?
Your code looks like it is running in an environment other than Unreal Editor, so the header file cannot be found.
Just tried it out and it seems to work for me. Maybe copying and pasting the path name is causing you problems?
This is what i did.
# Select two material assets in the content browser based on a bad to good order
mats = unreal.GlobalEditorUtilityBase.get_default_object().get_selected_assets()
replace_material(mats[0].get_path_name(), mats[1].get_path_name())
I had met this question like you ,
but I had solved this.
The reason why is that your object’s class is not the same,
such as first one is the material, another one is the Material Instance,
so it can not replace each other,
you must be make them class to be same,
hope this will be help for you