Download

Get reference to parent actor from ActorDetails customization class?

I have an actor, AMPCCamera, which has details panel customization. Specifically it adds a button to the properties panel for the actor. When that button is clicked I want to do some stuff that manipulates the properties of the actor, however I can’t figure out how to get a reference to my actor from the customizations class.

In the Wiki there is talk of binding properties, but that only appears to be a valid thing when inside of CustomizeDetails(), using the IDetailLayoutBuilder that is passed in. Sicne I am instead in a Slate button click delegate, I don’t have access to that either.

My first thought is to scrap the whole second class, and simply implement IDetailCustomization inside the main AMPCCamera actor class, but while that would probably simplify things, it appears contrary to the UE design pattern which I would rather stick with if possible.

Ok so for future reference, the way I worked this out is the following:

  1. In CustomizeDetails() use GetObjectsBeingCustomized() to get a reference to the actor
  2. In the button, use OnClicked_UObject() to pass the handler off to a method on the actual actor rather than in the details class

That will work, but generally you should try to keep editor-specific code out of your AActor class as much as possible. I think it’s better practice to create a clicked handler within your customization class. In CustomizeDetails(), you call GetObjectsBeingCustomized(), cast the result to your particular class, and store a pointer in a member of your customization class. Then in your clicked handler, you can call any function you like, or directly modify properties, through this pointer.

For reference, you can also store a pointer to the IDetailLayoutBuilder, and to any IPropertyHandles, inside your customization class. You can then access these from within your slate event handlers too.

From examples I saw and from some errors I ran into, it appeared at first glance that the customization class wasn’t supposed to have any member variables, which is why I went the direction I did. I will look at it again today though because you are right, the editor specific code should remain out. Though in our case it isn’t a huge deal since we deal only with the editor and never a game.