Is there any way to get property's value for Nesting Struct?

Hey guys.

If there are three struct

struct FStructChildA
{
	GENERATED_BODY()

     int  TestIntA

}

struct FStructChildB
{
	GENERATED_BODY()

     float  TestfloatB
     int GetTestIntA();
}

struct FStructParent
{
	GENERATED_BODY()

    FStructChildA  StructChildA ;
    
    FStructChildB  StructChildB ;
}

The FStructParent nest two others,if there is any method to get property‘s value in StructA by the member function which definition in StructB?

Why tho

If your FStructChildB cannot exist on its own and is always within FStructParent, you can do something like this

int GetTestIntA()
{
    FStructParent* Parent = (FStructParent*)( (uint8*)this - offsetof(FStructParent, StructChildB) );
    return Parent->StructChildA.TestIntA;
}

pls don’t do this

Thank your answer,I will try it.

I am new in coding,so it will be some strange idea .

At first,I think it use class should be better?
So that,I can get ChildB’s outer and cast it to parent,finally to get property in ChildA.

But if this method will take more memory,and there are so many class?

So I want to find another way to get it,and look for more learning.

thank again

Finally,I decide use UClass to realize it.For unreal 's reflect

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.