Let's talk about another useful feature in Reality. Reality API provides to aware of changing data on Reality Setup. With this feature, you can manipulate your code with “CustomEvent” when your variable is changed.

Conditions

  • Events name must start with “OnChanged_”.

  • The Variable must be public.

  • After “OnChange_” events name and variable must be the same.

  • Events names are case-sensitive.

Let's see with example.

  • Click to Add New button and Select the Blueprint Class.

  • Add an Actor Blueprint Class. Open it.

  • Open event graph.

  • Add ZD ACTOR component.

  • Add a new variable from “Variables” section under My Blueprint Tab. Make it public.

  • Add a new “CustomEvent”. Right-click and type “Add Custom Event”. 

  • Name must be “OnChanged_MyBooleanVariable”. (As you can see variable name and event name after “OnChanged_” is same.)

  • Add nodes as shown in below image.

  • When we change “MyBooleanVariable” the events will print value of boolean variable. This basic code for understanding how this feature is working.

  • Add ActorBlueprint to scene.

  • Click Play button and open Reality Setup.

  • Select MyActorBP node.

  • As you can see actor blueprint appears in Reality Setup. Thanks to ZD ACTOR component.

  • Variable also appear in the properties tab of MyActorBP.  Because we make it a public variable.

  • When you change “MyBooleanVariable”,  “OnChanged_MyBooleanVariable” event will work.