x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How do I use PostEditChangeProperty?

Say I have a boolean UPROPERTY called MyBool. I want it so that when this is ticked true in the editor (details panel of my custom actor), a function will run to set some misc members of that actor.

PostEditChangeProperty() seems to be what I want, but I don't get how to grab the value of the actual boolean. Here's what I have so far:

 void ASomeActor::PostEditChangeProperty(struct FPropertyChangedEvent& e)
 {
     FName PropertyName = (e.Property != NULL) ? e.Property->GetFName() : NAME_None;
     if (PropertyName == GET_MEMBER_NAME_CHECKED(AInteractable, MyBool)) {
         UBoolProperty* prop = ???
         if (prop) doThings();
         else undoThings();
     }
     Super::PostEditChangeProperty(e);
 }
Product Version: UE 4.7
Tags:
more ▼

asked Jul 05 '15 at 12:22 AM in C++ Programming

avatar image

sgp
166 32 41 56

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first
 /* If MyBool belongs to the ASomeActor */
 void ASomeActor::PostEditChangeProperty(struct FPropertyChangedEvent& e)
  {
      Super::PostEditChangeProperty(e);
 
      FName PropertyName = (e.Property != NULL) ? e.Property->GetFName() : NAME_None;
      if (PropertyName == GET_MEMBER_NAME_CHECKED(ASomeActor, MyBool)) {
              /* Because you are inside the class, you should see the value already changed */
                 if (MyBool) doThings(); // This is how you access MyBool.
                  else undoThings();
 
             /* if you want to use bool property */
             UBoolProperty* prop = static_cast<UBoolProperty*>(e.Property);
            if (prop->GetPropertyValue())
                dothings()
           else
                  undothings()
      }
  }
more ▼

answered Jul 05 '15 at 12:19 PM

avatar image

kishoreven
302 13 13 25

avatar image sgp Jul 05 '15 at 06:34 PM

Perfect, I should've realized that POSTEditProperty implied that it had already changed... Thanks!

avatar image Kafumanto Nov 25 '15 at 02:08 PM

Only to complete the great answer by @kishoreven, you can wrap the whole method inside WITH_EDITOR preprocessor definition:

 #if WITH_EDITOR
 void ASomeActor::PostEditChangeProperty(struct FPropertyChangedEvent& e)
 {
     // ...
 }
 #endif
 
avatar image darkgaze Jan 22 '18 at 03:51 PM

What if the property is located inside the code of a custom component on that actor, instead?

avatar image OSMET Jan 23 '18 at 09:59 PM

Also you can replace FName PropertyName = (e.Property != NULL) ? e.Property->GetFName() : NAME_None; by FName PropertyName = e.GetPropertyName();

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question