Yazhuo
(Yazhuo)
1
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?
Chatouille
(Chatouille)
2
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
Yazhuo
(Yazhuo)
3
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
Yazhuo
(Yazhuo)
4
Finally,I decide use UClass to realize it.For unreal 's reflect
system
(system)
Closed
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.