How can I get the classname of a struct property?

I am getting property Class Names using this code:

Target->FindPropertyByName(Name)->GetClass->GetFName();

this works for most things, however for structs, it simply returns “StructProperty” as the property className.

Id like to get the actual struct name, is that possible?

If I am not mistaken, you need to get the pointer from the FindPropertyByName() and cast it as FStructProperty and then you will receive the correct answer at GetClass->GetFName()

Thanks for the suggeston, it didnt seem to work though. This was my code. It returned “StructProperty” the same as before.

    FProperty* property = Target->FindPropertyByName(Name);

    FStructProperty* structProperty = Cast<FStructProperty>(property);
    if (structProperty)
    {
        name = structProperty->GetClass()->GetFName();
        return name;
    }

I have checked some of my code library and found that from the property you will use (did with your code):

FProperty* property = Target->FindPropertyByName(Name);

FStructProperty* structProperty = Cast<FStructProperty>(property);
if (structProperty)
{
    name = structProperty->Struct->GetClass()->GetFName();
    return name;
}

Obs: the difference is the Struct pointer in the middle.

It is useful to look at some engine source to find this type of hint. Usually I look at the source where tools handle information found in blueprints and structs.

Im not sure I understand your right. Are you saying I should not be using FStructProperty?

I have just changed your own code in my previous post. It will work. It is important to use certain functions with the correct pointer, so my suggestion is to keep using FStructProperty.

ooh, is see it now, thankyou. That returns “ScriptStruct”, but that is not the struct’s classname.

I tried removing the “GetClass()” part of the code, and now it works properly.

FProperty* property = Target->FindPropertyByName(Name);

FStructProperty* structProperty = Cast<FStructProperty>(property);
if (structProperty)
{
    name = structProperty->Struct->GetFName();
    return name;
}