but then it throw an error that I should pass StaticMeshEditorSubsystem?
Any idea what is StaticMeshEditorSubsystem?
here is my python code: (Also I’m running this in UE5)
import unreal
editor_util = unreal.EditorUtilityLibrary()
selected_assets = editor_util.get_selected_assets()
for asset in selected_assets:
# # deprecated
# result = unreal.EditorStaticMeshLibrary.get_number_materials(asset)
# new class
result = unreal.StaticMeshEditorSubsystem.get_number_materials(asset)
Still no answer? I too am getting this warning in UE5 when using EditorStaticMeshLibrary:
LogPython: Warning: <string>:1: DeprecationWarning: EditorStaticMeshLibrary: Function 'get_lod_build_settings' on 'EditorStaticMeshLibrary' is deprecated: The Editor Scripting Utilities Plugin is deprecated - Use the function in Static Mesh Editor Subsystem
When I switch over to use StaticMeshEditorSubsystem I get this error:
Error: TypeError: descriptor 'get_lod_build_settings' requires a 'StaticMeshEditorSubsystem' object but received a 'StaticMesh'
selected_assets = unreal.EditorUtilityLibrary.get_selected_assets()
asset = selected_assets[0]
# After switching from deprecated EditorStaticMeshLibrary to StaticMeshEditorSubsystem,
# we have to get the default static mesh object first and get_lod_build_settings from it
default_staticmesh_object = unreal.StaticMeshEditorSubsystem.get_default_object()
lod_build_settings = default_staticmesh_object.get_lod_build_settings(asset, 0)
# make a change to one of its properties
lod_build_settings.set_editor_property('generate_lightmap_u_vs', False)
# now write the lod_build_settings back to the asset
default_staticmesh_object.set_lod_build_settings(asset, 0, lod_build_settings)