hololens和unity

主要参考的微软官网的教程,汉语版的介绍的都太粗糙,不好用。gaze, gesture,代码交互。参看https://docs.microsoft.com/zh-cn/windows/mixed-reality/holograms-101e
在这里插入图片描述在这里插入图片描述Instructions
Start Unity.
Select Open.
Enter location as the Origami folder you previously un-archived.
Select Origami and click Select Folder.
Save the new scene: File / Save Scene As.
Name the scene Origami and press the Save button.
Setup the main camera
In the Hierarchy Panel, select Main Camera.
In the Inspector set its transform position to 0,0,0.
Find the Clear Flags property, and change the dropdown from Skybox to Solid color.
Click on the Background field to open a color picker.
Set R, G, B, and A to 0.
Setup the scene
In the Hierarchy Panel, click on Create and Create Empty.
Right-click the new GameObject and select Rename. Rename the GameObject to OrigamiCollection.
From the Holograms folder in the Project Panel:
Drag Stage into the Hierarchy to be a child of OrigamiCollection.
Drag Sphere1 into the Hierarchy to be a child of OrigamiCollection.
Drag Sphere2 into the Hierarchy to be a child of OrigamiCollection.
Right-click the Directional Light object in the Hierarchy Panel and select Delete.
From the Holograms folder, drag Lights into the root of the Hierarchy Panel.
In the Hierarchy, select the OrigamiCollection.
In the Inspector, set the transform position to 0, -0.5, 2.0.
Press the Play button in Unity to preview your holograms.
You should see the Origami objects in the preview window.
Press Play a second time to stop preview mode.
Export the project from Unity to Visual Studio
In Unity select File > Build Settings.
Select Windows Store in the Platform list and click Switch Platform.
Set SDK to Universal 10 and Build Type to D3D.
Check Unity C# Projects.
Click Add Open Scenes to add the scene.
Click Player Settings…
In the Inspector Panel select the Windows Store logo. Then select Publishing Settings.
In the Capabilities section, select the Microphone and SpatialPerception capabilities.
Back in the Build Settings window, click Build.
Create a New Folder named “App”.
Single click the App Folder.
Press Select Folder.
When Unity is done, a File Explorer window will appear.
Open the App folder.
Open the Origami Visual Studio Solution.
Using the top toolbar in Visual Studio, change the target from Debug to Release and from ARM to X86.
Click on the arrow next to the Device button, and select HoloLens Emulator.
Click Debug -> Start Without debugging or press Ctrl + F5.
After some time the emulator will start with the Origami project. When first launching the emulator, it can take as long as 15 minutes for the emulator to start up. Once it starts, do not close it.
在这里插入图片描述在这里插入图片描述
后来遇到了新的模拟器的错误,提示: hololens emulator虚拟磁盘系统限制无法完成请求操作

把C:\Users\Acer\AppData\Local\Microsoft\XDE 文件夹的属性 改为非压缩(在高级。。按钮中),其下面的10.0.17134.0文件夹也要改掉。我操作时把他们的只读属性也去掉了,马上解决了问题。虚拟机又正常打开并看到我的程序了。

官方的例子解决以后,我自己又建了一个新的工程,hololenscube,用的默认的相机(颜色设为solid,纯黑即全0背景),默认的光线.相机的位置设为0,0,0。cube的位置设为0,0,3,因为hololens在两三米的位置显示的效果最好。另外绕y轴旋转了30度。然后就是切换到UWP平台,target Device选Hololens,SDK选安装的17134版本,勾选C# projects选项(如果是灰色的就需要按下面的说明在player settings设置后才行),并进行player settings设置。
player settings…中的other settings菜单中 scripting backend 记得一定要选.NET,且只有选了.NET 后build settings对话框中的unity C# PROJECTS才能打勾。
在这里插入图片描述
XR settings中一定要勾选virtual Reality supported选项。
另外记得publishing settings中的capabilities选择需要的功能,否则可能hololens真机无法互动、上网等,我这里只选择了两个:microphone和spatialperception.

以上部署到hololens emulator没问题。然后我又通过USB口部署到了一代真机上。
步骤如下:

  1. 插入真机
  2. VS2017选择 release(debug版本应该也可以,虚拟机我用的debug),X86, Device
  3. 点击绿色按钮运行
  4. 然后VS2017会弹出一个对话框,要求输入PIN
  5. 在hololens 中打开Setting(设置)应用,
    选择Update & Security(更新和安全),
    选择For developers(面向开发人员),
    启用Developers Mode(On) (开发人员模式),
    向上拖动到底,然后启用 Device Portal(On)。
    点击pair按钮,生成的数字串(即前面需要的PIN码),我这里为353320
    在这里插入图片描述
    然后把此数字输到VS2017所弹出的对话框中,成功运行,APP成功安装到hololens上并运行。

备注:我昨天用了一般网上说的request pin 并不行。也可能是上次我输了两次pin码的缘故,第一次生成的忘了,所以又生成了一次,听说一个程序只能pin,然后无法再改。如果新程序只输入一次,按说应该可以的。当时全是7位的数字,可这次是6位的。
在这里插入图片描述

上文中所说的一般的方法如下:
通过USB连接到PC,在第一次进行部署时,需要在PC中用浏览器打开 http://127.0.0.1:10080 界面进行用户配置,会打开一个设置页面,点击Request pin,然后在HoloLens上查看生成的pin码,输入设备上出现的pin码,输入一个用户名用于连接HoloLens,重复输入密码,密码至少要有7个字符,不必是微软账号或者域账号密码,点击 Pair按钮来连接到HoloLens。(参考https://blog.csdn.net/qq_21153225/article/details/81904876 )
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值