Get Polycount on runtime

I want to get the poly count of a array of Skeletal mesh on Runtime.

I have sequences with different test animations for a Skeletal meshes. I can iterate through the skeletal meshes and change for Example LOD settings.

What i want to know is. How to get the information of the polygon count per skeletal mesh.

I tried the static mesh description. but this is always empty. Even if i input a static mesh.

Do i need to define something in the mesh description or create first static meshes out of the skeletal meshes to use this function ?

Hey there,

For blueprint, specifically, this data isn’t available. You will need to write some code to be able to access this data. You can use a function library approach, exposing your function to blueprint, then you’ll have access to your APIs. It would look roughly something like:

Header

`UCLASS()
class YOURGAME_API UYOURGAMEMeshFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:

UFUNCTION(BlueprintCallable, Category = “Mesh Utilities”)
static int32 GetNumOfTrianglesForSkeletalMesh(USkeletalMesh InSkeletalMesh, int32 LODIndex);
};` Code

`#include “YOURGAMEBlueprintFunctionLibrary.h”
include “Rendering/SkeletalMeshRenderData.h”

int32 UYOURGAMEBlueprintFunctionLibrary::GetNumOfTrianglesForSkeletalMesh(USkeletalMesh* InSkeletalMesh, int32 LODIndex)
{
FSkeletalMeshRenderData* RenderData = InSkeletalMesh->GetResourceForRendering();
if(RenderData->LODRenderData.IsValidIndex(LODIndex))
{
return RenderData->LODRenderData[LODIndex].GetTotalFaces();
}

// Return a value so that you know something doesn’t exist.
return -1;
}`

Dustin

Thx for the fast feedback. This solution works for me. I needed to change a little bit because i have skeletal mesh actor so i need to get first the Skeletal mesh. But still works great thx.