After migrating to UE5.2, (from 5.1), many of my materials are showing up as the default material in game but they look normal in the material editor. I’ve found that right clicking on a material and going to Asset Actions → Reload fixes it but I have way too many materials to do this one by one. Any ideas?
So I found out why. I have Nanite enabled in my project and for whatever reason, if you don’t have “Used with Nanite” on in the materials, it just doesn’t work in 5.2. This wasn’t a problem in 5.1 and it’s dumb that they expect me to do this manually for hundreds of materials. I made a python script to do this for me if any of you run into the same issue.
# This file is used to enable the "Used With Nanite" property of every material
import unreal
classNames = unreal.Array(unreal.Name)
classNames.append(unreal.Name("Material"))
packagePaths = unreal.Array(unreal.Name)
packagePaths.append(unreal.Name('/Game'))
myFilter = unreal.ARFilter(class_names=classNames, package_paths=packagePaths, recursive_paths=True)
asset_reg = unreal.AssetRegistryHelpers.get_asset_registry()
assetsData = asset_reg.get_assets(myFilter)
for assetData in assetsData:
uobject = assetData.get_asset()
uobject.set_editor_property("bUsedWithNanite", True)