Responding to property – changed events from the editor

When a designer changes the properties of an Actor placed in the level, it is often important to show any visual results of that change immediately rather than just when the level is simulated or played.

When changes are made using the Details panels, there's a special event that the editor emits called PostEditChangeProperty, which gives the class instance a chance to respond to the property being edited.

This recipe shows you how to handle PostEditChangeProperty for immediate in-editor feedback.

How to do it…

  1. Create a new Actor called APostEditChangePropertyActor based on StaticMeshActor.
  2. Add the following UPROPERTY to the class:
    UPROPERTY(EditAnywhere)
    bool ShowStaticMesh;
  3. Add the following function ...

Get Unreal Engine 4 Scripting with C++ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.