ARFoundation road - environment configuration (iOS) one

  Earlier we covered the development environment configuration and release deployment ARFoundation develop Android applications, this article focuses on using the Unity development ARFoundation AR application environment configuration and release deployed on Mac computers, ARFoundation used in iOS end is the underlying technology ARKit, and Unity iOS project can not be published as a one-time package file, using the Unity ARFoundation released iOS AR application requires two steps: The first step in using Unity generate XCode project file, the second step using the XCode project files to compile ipa file publishing applications, this article assumes that the reader has installation Unity2019.1 version of XCode 10.

(A) introducing widget

  Now we will create a new project, and import ARFoundation and ARKit XR Plugin. Click on the program icon in the dock or the dock Unity (Unity Hub or icon) to start Unity, click New to create a new project, select the project type, project name and project to fill in the stowed position, we named Helloworld, and finally click the bottom right corner of the "Create" button to create a project, as shown below.
Here Insert Picture Description
  Unity to be window opens, click on the menu bar Unity window-> Package Manager, Package Manager dialog box opens.

Here Insert Picture Description
  Package Manager dialog box is not displayed by default ARFoundation and ARKit XR Plugin, because these plug-ins are currently in a preview state. Click the Advanced dialog box drop-down menu, select Show preview package, which will preview all of the plug-ins are also displayed.
Here Insert Picture Description
Here Insert Picture Description
  It should be noted that, at present ARKit official version is 2.0, XCode official version is 10.2, this time if we installed directly ARFoundation2.2 and ARKit XR Plugin2.2 compile error will be reported as follows:

Undefined symbol: OBJC_CLASS$_ARCollaborationData
Undefined symbol: OBJC_CLASS$_ARSkeletonDefinition
Undefined symbol: OBJC_CLASS$_ARBodyAnchor
Undefined symbol: OBJC_CLASS$_ARBodyTrackingConfiguration
Undefined symbol: OBJC_CLASS$_ARMatteGenerator

  原因是ARFoundation2.2包含还未发布的ARKit3.0的实验内容,而编译运行ARKit3.0至少需要Xcode 11 beta和iOS 13 beta,为简单起见,这里我们不安装ARFoundation2.2而是安装2.1版,步骤如下:在上图中点击ARFoundation左侧的小三角图标,打开折叠栏,然后点击“See all versions”文字链接,展开版本选择栏,选中Preview.3 - 2.1.0,然后带你点击详情窗口右下角的“Install”安装,如下图所示。如此操作,再将ARKit XR Plugin2.1版也安装上。
Here Insert Picture Description
Here Insert Picture Description
  至此,已经将开发iOS的AR所需插件都导入了。

(二)设置开发环境

  在Unity窗口中,按Command+Shift+B快捷键,或者在菜单栏中选择File->Build Settings…,打开设置窗口。选择“Platform”下的“iOS”选项,然后单击“Switch Platform”按钮切换到iOS平台。当Unity标志出现在iOS选项旁边时,发布平台就切换成iOS了,如下图所示。
Here Insert Picture Description

  单击左下方的“Player Settings”按钮继续后续设置,如下图所示,按顺序依次选择Player,在Player栏中Company Name与Product Name中填写公司名与产品名,选择iOS平台小图标,展开Other Setting选项卡,如下图所示。
Here Insert Picture Description
  在Identification栏中,PackageName填写应用程序包名,建议与上图Company Name和Product Name中输入的公司和程序包名一致,这个值要求唯一,因为如果它与另一个应用程序具有相同的包名,可能会导致问题。并设置好应用程序的版本号,如下图所示。
Here Insert Picture Description
  继续往下滚动,填写使用摄像机的请求信息,这会在AR应用第一次启动时向用户请求摄像机使用权限。设置好Target Device,目标设备可以是iPhone,也可以是iPad,也可以同时为iPhone+iPad。因为我们使用真机进行应用调试,我们设置Target SDK为Device SDK。设置最低iOS系统版本为11.0,因为支持ARKit的最低iOS版本是11.0。最后设置处理器架构为ARM64。
Here Insert Picture Description
  细心的读者可能已经发现,在上图中有一个“Requires ARKit support”选项,这个选项可以勾选,也可以不勾选,不影响AR应用。至此,我们已完成了利用ARFoundation开发iOS AR应用的环境配置工作。

(三)搭建基础框架

  在完成以上设置后,下面我们来搭建ARFoundation开发AR应用的基础框架,这个基础框架所有AR应用通用。在Project窗口Scenes文件夹中,我们重命名场景文件为“Helloworld”,同时,为后面统一管理文件,在Projects窗口Assets目录下新建Prefabs、Scripts两个文件夹,然后在Hierarchy窗口中删除Main Camera(因为ARFoundation AR Session Origin只带有一个AR摄像机,Directional Light可根据需要决定是否删除),如下图所示。
Here Insert Picture Description
  在Hierarchy窗口中的空白处点击鼠标右键,在弹出的级联菜单中依次选择XR–>AR Session和XR–>AR Session Origin,新建这两个AR基础组件。
Here Insert Picture Description
  在Hierarchy窗口中的空白处点击鼠标右键,在弹出的级联菜单中依次选择XR–>AR Default Plane,将Hierarchy窗口中生成的AR Default Plane拖动到Project窗口中的Prefabs文件夹下,制作一个平面prefab,如下图所示,然后删除Hierarchy窗口中的AR Default Plane对象。
Here Insert Picture Description
  在Hierarchy窗口选中AR Session Origin对象,然后在Inspector窗口中点击Add Component按钮,在弹出的搜索中搜索“AR Plane Manager”,并添加该组件,如下图所示。
Here Insert Picture Description
  将Project窗口中Prefabs文件夹下的AR Default Plane拖到AR Plane Manager组件下的Plane Prefab属性框,如下图所示。
Here Insert Picture Description
  So far, the basic framework AR applications we've built a good, this is a basic framework to develop ARFoundation iOS AR applications, processes common. And by comparing the earlier we can find, on the basis of the framework set up, fully consistent with the Android Development iOS development, we will see later, the code is written exactly the same, which is the meaning of ARFoundation appears that a multi-platform development deployment, in addition to environment configuration is different, other objects and coding are the same, eliminating the trouble of developers to develop applications on different platforms AR.

Guess you like

Origin blog.csdn.net/yolon3000/article/details/93405795