简体   繁体   English

如何将 .rcproject 文件导入到 Xcode 项目中?

[英]How to import an .rcproject file into a Xcode project?

If I load an AR Game template it creates a file called Experience which is a Reality Composer file that you can reference in code.如果我加载一个 AR 游戏模板,它会创建一个名为 Experience 的文件,这是一个您可以在代码中引用的 Reality Composer 文件。 So you can see here:所以你可以在这里看到:

let boxAnchor = try! Experience.loadBox()

在此处输入图像描述

Which is good... but how do I do this in my project?哪个好...但是我如何在我的项目中执行此操作? I created a Reality Composer file and added it to the project, but I cannot reference it?我创建了一个 Reality Composer 文件并将其添加到项目中,但我无法引用它?

在此处输入图像描述

在此处输入图像描述

And I cannot seem to find the additional link I need to add here to make it work?而且我似乎找不到我需要在此处添加以使其正常工作的附加链接? Do I have to call the file "Experience.rcproject", surely not?我一定要把文件称为“Experience.rcproject”吗?

To load another Reality Composer scene (enumeration), you have to take four steps:要加载另一个 Reality Composer 场景(枚举),您必须执行四个步骤:

  1. Rename rook16.rcproject to Rook16.rcproject in Xcode Navigator pane.在 Xcode Navigator 窗格rook16.rcproject重命名为Rook16.rcproject
  2. Consider Swift's enum naming convention.考虑 Swift 的枚举命名约定。 Write Rook16.loadBox() .编写Rook16.loadBox()
  3. Select Rook16 in Navigator, go to Inspector (file tab) and tick a Target Membership.在 Navigator 中选择Rook16 ,转到 Inspector(文件选项卡)并勾选 Target Membership。
  4. Restart your project in Xcode.在 Xcode 中重新启动您的项目。

Here's the SwiftUI code:这是 SwiftUI 代码:

func makeUIView(context: Context) -> ARView {
    let arView = ARView(frame: .zero)
    let rook16 = try! Rook16.loadBox()
    arView.scene.anchors.append(rook16)
    return arView
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM