I saw onnoffitacation in the Behavior configuration of Reality Composer pro, which asked me to enter the Nofficatition name, that is to say, this requires swift in Xcode to send a message. There is a message name in the message, so I hope you can write an list for me how to use Swift in Xcode to send a message containing the message name.
Send messages to the scene
Use the following snippet to post the notification.
NotificationCenter.default.post(
name: NSNotification.Name("RealityKit.NotificationTrigger"),
object: nil,
userInfo: [
"RealityKit.NotificationTrigger.Scene": scene,
"RealityKit.NotificationTrigger.Identifier": "Name_You_Provided_On_Trigger_In_RCP"
]
)
In the above snippet, scene
refers to the RealityKit scene.
@Environment(\.realityKitScene) var scene
Note: The interaction system won't be ready to receive Notifications right away, so wait at least half a second after loading your content before posting the notification.
Thanks for the reply and I believe my timeline is triggered by this notification. Because I append a notification action in this timeline and in my code I can receive the message from that action.
However, the TransformTo and Hide actions in the same timeline doesn't seem to be triggered. I have played that timeline in RCP, it went well. Note that TransformTo and Notification actions are targeted to the same Entity in the scene. And my Hide action targeting to a child entity of it. Any idea why this may happen? Thanks.
(I also tried using applyTapForBehaviors on the entity, but it;s still not working