Мне нужно, чтобы мой код отправлял уведомление на сцену RCP, которая воспроизводит временную шкалу. В интерфейсе RCP есть возможность настроить поведение для этой цели:

и этот пост SO «Отправить уведомление из SwiftUI Xcode 16 для запуска анимации действия временной шкалы Reality Composer Pro», а также эту ветку форума. https://developer.apple.com/forums/thread/756978 покажите код, который мне нужен для отправки уведомления:
NotificationCenter.default.post(
name: NSNotification.Name("RealityKit.NotificationTrigger"),
object: nil,
userInfo: [
"RealityKit.NotificationTrigger.Scene": scene,
"RealityKit.NotificationTrigger.Identifier": "HideCharacter"
]
)
но переменная 'scene' должна указывать на соответствующую сцену RCP, которая загружается в UIViewRepresentable ARView (потому что мне нужно использовать ARKit), и я не могу понять, как правильно получить к ней доступ. Примеры по ссылкам выше предназначены для работы с RealityKit, VisionOS или просто не обеспечивают достаточного контекста.
Код для загрузки сцены выглядит следующим образом. Как я могу получить приведенный выше код уведомления, расположенный за пределами ARView, для доступа к этой сцене?
struct ARViewContainer: UIViewRepresentable {
typealias UIViewType = ARView
let logger = Logger(subsystem: "com.apple.torquest", category: "ARViewContainer")
// Start observing locationsHandler to access name of required AR Scene
@ObservedObject var locationsHandler = LocationsHandler.shared
func makeUIView(context: Context) -> ARView {
// Create an ARView
let arView = ARView(frame: .zero)
// Configure it
let arConfiguration = ARWorldTrackingConfiguration()
arConfiguration.planeDetection = [.horizontal]
arConfiguration.environmentTexturing = .automatic
arConfiguration.frameSemantics.insert(.personSegmentationWithDepth)
arView.environment.sceneUnderstanding.options.insert(.occlusion)
arView.session.run(arConfiguration)
// Load in Reality Composer Pro scene
let scene = try! Entity.load(named:"myScene)", in: realityKitContentBundle)
// Create a horizontal plane anchor
let anchor = AnchorEntity(.plane(.horizontal, classification: .any, minimumBounds: SIMD2(0.2, 0.2)))
// Append the scene to the anchor
anchor.children.append(scene)
// Append the anchor to the ARView
arView.scene.anchors.append(anchor)
return arView
}
func updateUIView(_ uiView: ARView, context: Context) {
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... ble-arview
Мобильная версия