24.5 C
Canberra
Saturday, January 3, 2026

Find out how to entry a Actuality Composer Professional scene in a UIViewRepresentable ARView?


I’m creating an Augmented Actuality iOS (Not VisionOS) app utilizing scenes created in Actuality Composer Professional.

I would like my code to ship a notification to a RCP scene that performs a timeline. The RCP interface has the choice to arrange a behaviour for this function:

Find out how to entry a Actuality Composer Professional scene in a UIViewRepresentable ARView?

and each this SO put up Ship Notification from SwiftUI Xcode 16 to set off Actuality Composer Professional Timeline Motion Animation and this Discussion board thread https://developer.apple.com/boards/thread/756978 present the code I want for sending a notification is:

NotificationCenter.default.put up(
  title: NSNotification.Identify("RealityKit.NotificationTrigger"),
  object: nil,
  userInfo: [
    "RealityKit.NotificationTrigger.Scene": scene,
    "RealityKit.NotificationTrigger.Identifier": "HideCharacter"
  ]
)

however the ‘scene’ var must level to the related RCP scene, which is loaded inside a UIViewRepresentable ARView (as a result of I want to make use of ARKit) and I am unable to work out tips on how to appropriately entry it. The examples within the hyperlinks above are for working with RealityKit, VisionOS or simply do not present sufficient context.

Code for loading the scene is as follows. How can I get the notification code above, located out of the scope of the ARView, to entry this scene?

struct ARViewContainer: UIViewRepresentable {
    
    typealias UIViewType = ARView
    
    func makeUIView(context: Context) -> ARView {
        
        // Create an ARView
        let arView = ARView(body: .zero)
        
        // Configure it
        let arConfiguration = ARWorldTrackingConfiguration()
        arConfiguration.planeDetection = [.horizontal]
        arConfiguration.environmentTexturing = .computerized
        arConfiguration.frameSemantics.insert(.personSegmentationWithDepth)
        arView.setting.sceneUnderstanding.choices.insert(.occlusion)
        arView.session.run(arConfiguration)
        
        // Load in Actuality Composer Professional scene
        let scene = strive! Entity.load(named:"myScene)", in: realityKitContentBundle)
        
        // Create a horizontal airplane anchor
        let anchor = AnchorEntity(.airplane(.horizontal, classification: .any, minimumBounds: SIMD2<Float>(0.2, 0.2)))
        
        // Append the scene to the anchor
        anchor.kids.append(scene)
        
        // Append the anchor to the ARView
        arView.scene.anchors.append(anchor)
        
        return arView
    }
    
    func updateUIView(_ uiView: ARView, context: Context) {
    }
}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles