LoginSignup
0
0

More than 3 years have passed since last update.

Reality composer のオブジェクトをタップで Xcodeに通知

Last updated at Posted at 2020-09-10

Reality Composerで編集

下図のようにビヘイビアを設定
スクリーンショット 2020-10-09 9.01.02.png

Xcodeで編集

import UIKit
import RealityKit

class ViewController: UIViewController {

    @IBOutlet var arView: ARView!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Load the "Box" scene from the "Experience" Reality File
        let boxAnchor = try! Experience.loadBox()

        //追記「tapped」は上記図の赤枠で設定
        boxAnchor.actions.tapped.onAction = handleTapOnEntity(_:)

        // Add the box anchor to the scene
        arView.scene.anchors.append(boxAnchor)
    }

    //関数を追記
    func handleTapOnEntity(_ entity: Entity?) {
          guard let entity = entity else { return }
          // Do something with entity...
        print(entity) //Do something
      }
}

 

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0