Hello [mention removed],
Sorry about the delay. You’re correct that using md5() directly on a .uasset file will yield different results when the asset is moved or duplicated. This happens because .uasset files contain internal metadata that vary on duplication, relocation and other engine operations.
To compare actual mesh content, it’s better to extract and evaluate the internal geometry via the Python API rather than relying on the raw file hash.
I’m sharing a script that computes a hash based on the Static Mesh’s vertex positions and material slot names. These properties are stable and consistent across save and remain unchanged when moving the asset to a different folder or duplication within the editor.
`import unreal
import hashlib
import json
def generate_static_mesh_instance_hash(asset_path: str, lod_index: int = 0) → str:
mesh = unreal.EditorAssetLibrary.load_asset(asset_path)
if not isinstance(mesh, unreal.StaticMesh):
raise TypeError(f"{asset_path} is not a StaticMesh")
mesh_desc = mesh.get_static_mesh_description(lod_index)
if not mesh_desc:
raise RuntimeError(f"Could not get StaticMeshDescription for LOD {lod_index}")
Vertex positions only
vertex_positions =
for i in range(mesh_desc.get_vertex_count()):
vertex_id = unreal.VertexID(i)
if mesh_desc.is_vertex_valid(vertex_id):
pos = mesh_desc.get_vertex_position(vertex_id)
vertex_positions.append([
str(round(pos.x, 6)),
str(round(pos.y, 6)),
str(round(pos.z, 6))
])
Material names only
material_names = [mesh.get_material(i).get_name() if mesh.get_material(i) else “None”
for i in range(len(mesh.static_materials))]
data = {
“vertices”: vertex_positions,
“materials”: material_names,
}
content_string = json.dumps(data, separators=(“,”, “:”), sort_keys=True)
h = hashlib.new(“sha256”)
h.update(content_string.encode(“utf-8”))
return h.hexdigest()
Example usage
print(generate_static_mesh_instance_hash(“/Game/SM_Cone”))`Running this from the Python console in the editor will return a content-based hash for the given Static Mesh asset (e.g “Game/SM_Cone”). Hash remains consistent as long as the geometry and materials are unchanged.
Please let me know if this information is helfpul.
Best,
Francisco