Announcement

Collapse
No announcement yet.

[How to] modify struct in details customization

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Originally posted by BrUnO XaVIeR View Post
    Yes.. I get the child handle to modify child values.
    Yeah, but as far as I know you can't work with arrays this way. You can only set the value if it's a primitive type, an FString, a UObject* or a few other types.

    Leave a comment:


  • replied
    Yes.. I get the child handle to modify child values.

    Leave a comment:


  • replied
    I feel so stupid, it was working all along. The problem was my UI that was displaying incorrect data. Well, 4 hours wasted but I got it to work (finally). I won't delete this thread because someone might be interested in knowing how to do this stuff.

    Btw, BrUnO XaVIeR I think you misunderstood the problem. What you're doing there is getting a child handle, not the value of the struct. Thanks anyway!

    Leave a comment:


  • replied
    I do it naive way:

    Code:
    TSharedPtr<IPropertyHandle> PropHandle;
    Code:
    PropHandle = StructPropertyHandle->GetChildHandle(index).ToSharedRef();
    
    if ( ! PropHandle->IsValidHandle() ) { return; }
    
    //...

    Leave a comment:


  • started a topic [How to] modify struct in details customization

    [How to] modify struct in details customization

    NOTE: This was a question initially, but the problem was my UI displaying incorrect data. This part of the code works, so I have edited the post (and title) for anyone trying to do the same!

    To set your struct, you first get a pointer to it using the IPropertyHandle that the CustomizeChildren provides.

    Code:
    FMyStruct* FMyStructCustomization::GetData()
    {
        TArray<UObject*> objects;
        handle->GetOuterObjects(objects);
    
        return (FMyStruct*)handle->GetValueBaseAddress((uint8*)objects[0]);
    }
    Then, to change the values you get a pointer to the struct and modify it's values. Simple as that!
    Code:
    handle->NotifyPreChange();
    
    FMyStruct* data = GetData();
    
    data->dummyFloatArray.Add(0);
    data->dummyBool = true;
    
    handle->NotifyPostChange(EPropertyChangeType::ValueSet);
    Last edited by ItsaMeTuni; 01-06-2019, 05:48 PM.
Working...
X