In this part, we will make the watch hidden by default and show it in a few seconds by pressing a controller button. There are various ways to get controller input with Unity. This time, we will use OpenVR Input API (SteamVR Input). Prerequisite setting Open the SteamVR Settings. Toggle Advanced Settings. Toggle Developer > Enable debugging options in the input binding user interface to On. Create action manifest SteamVR Input uses abstracted actions instead of direct access to the physical buttons.
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by using Valve.VR
Part 9 - Overlay Events
Show the current time on the right hand Let’s display the current time on the right hand. Add a variable in WatchOverlay.cs to determine which hand to show the current time. OpenVR has ETrackedControllerRole type representing the left or right hand, so we use this.
Part 8 - Dashboard Overlay
Let’s create a setting screen on the SteamVR dashboard. It switches which hand to display the watch overlay. Create dashboard overlay Dashboard overlay is an overlay that is displayed on the SteamVR dashboard. We use this overlay as the setting screen. Create DashboardOverlay.cs inside Scripts folder and copy the following code.
Part 7 - Draw Camera Output
Prepare camera output Before displaying the current time to the watch overlay, try displaying the camera output of a simple 3d scene. In the hierarchy window, create the following game objects. Camera 3D Object > Cube Light > Directional Light Arrange the objects as the camera captures the cube. It’s OK to arrange roughly. We want to make animated camera output so create a script to rotate the cube. Create Rotate.cs inside the Scripts folder, then copy the following code.
Part 6 - Follow Device
Follow the HMD Overlay following the HMD First, remove the absolute position code we added in the previous part.
Part 5 - Change Size and Position
Change overlay size Pass width to set an overlay size (read the wiki for details). The width unit is meters. Height is automatically calculated based on the image aspect ratio. The default width is 1 m. Change the overlay width to 0.5 m.
Part 4 - Draw Image
Prepare an image file Prepare an image file that satisfies the following conditions. Size is lower than 1920 x 1080 px. File format is in PNG, JPG, or TGA (24 or 32 bit color) From here on, I explain with my SNS icon named “sns-icon.jpg”. Put the image file inside Assets/StreamingAssets folder. Draw image Call to draw an image file.
Part 2 - Initialize OpenVR
Create new script Create a folder named Scripts inside Assets. Then create a file named WatchOverlay.cs inside the Scripts folder. We will add our overlay code to this script. Copy the following code to WatchOverlay.cs. using UnityEngine; public class WatchOverlay : MonoBehaviour { private void Start() { } } Put the script to the scene In the hierarchy window, right click > Create Empty.
Unity SteamVR入门_set range of motion on pickup-CSDN博客
VR项目现在在当前已经是非常热门的技术,可以给玩家身临其境的感觉,接下来让我们学习这部分的内容吧! SteamVR Input SteamVR绑定流程,在Windows窗口的点击SteamVR-input,图1,在这里可以选择你需要绑定的事件,给事件添加对应的功能再可以取个名字用来在按键绑定的时候使用,图2,就是使用到你绑定的触发事件,比如给按键添加一个按下抬起的功能,这里就需要一个Bool类型的变量,按下的时候为TRUE,抬起的时候为FALSE,然后就可以在代码中调用对应的事件触发相应的功能 脚本声明方法 using Valve.VR; public SteamVR_Action_Boolean action = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("Action"); void Update() { if (SteamVR_Input.GetStateDown("action", SteamVR_Input_Sources.RightHand)) { Debug.Log("按下"); } if...
Unity SteamVR 开发教程:用摇杆/触摸板控制人物持续移动(2.x 以上版本)
持续移动是 VR 开发中的一个常用功能。一般是用户推动手柄摇杆,或者触摸手柄触摸板,来控制人物持续地移动。Unity SteamVR 插件中只提供了传送的移动功能,而没有用摇杆或触摸板控制人物持续移动的功能。因此,持续移动的功能需要我们自己开发。 📕教程说明 使用的 Unity 版本: 2021.3.5 使用的操作系统:Windows 11 使用的设备:Meta Quest 2 SteamVR 版本:2.7.3 因为我用的是 Quest 手柄,所以我会用 Quest 手柄的摇杆控制人物移动。而像 Htc Vive 手柄上只有触摸板 Touchpad,但是它的作用和摇杆是一样的。 最终实现的效果:能通过摇杆控制人物持续移动,人物能与其他物体有碰撞,能上阶梯。 📕场景搭建 我们新建一个场景,删除原本场景中的 Main Camera,在场景中放置一个平面,然后用方块制作一个阶梯,用于后续的测试。接下来,我们需要添加一个 VR 中代表玩家自己的物体。我可以打开 Assets/SteamVR/InteractionSystem/Core 文件夹,将 Player 物体拖入场景:...
Unity SteamVR 2.x UGUI射线交互 +物品射线点击+物品抓起(超级简单)
刚开始先查看了其他道友的方案:1.Unity使用SteamVR2.0实现基本功能(瞬移,抓取物品,射线点击,UI交互等)_贪小心的博客-CSDN博客_unity steam vr 2.【Steam VR 2.0】5.射线操作UGUI-射线点击物体_恩博同学的博客-CSDN博客_htc steamvr 射线点击ui 嗯。。。试着尝试了一下,不是很好用,于是乎记得以前用过得的方法(别人做的,我只是使用者),剔除出来,整理一下。 一 UGUI射线点击: 使用插件:CurvedUI(CurvedUI+DOTween+Shaders+Sprites-其它文档类资源-CSDN文库),SteamVR Plugin(商店免费) 场景使用SteamVR 的Interactions_Example场景测试的 1.将CurvedUI 下的CurvedUILaserPointer预制体 放置 SteamVR的 Player 下。 其他设置 二 物品射线点击: 继承重写类:CurvedUILaserBeam using UnityEngine; using System.Collections;...
Unity HDRP下VRTK传送、穿墙 时画面淡入淡出、视觉遮挡无法正确显示问题解决
Unity HDRP下VRTK传送、穿墙 时画面淡入淡出、视觉遮挡无法正确显示问题解决 Unity HDRP的渲染方式和普通Unity有所不同,而SteamVR插件中负责VR画面淡入、淡出的脚本“SteamVR_Fade”是通过在相机渲染一帧后执行的方法OnPostRender调用GL.QUADS去执行绘制一个片,然后使用Shader控制这个片的颜色、渐变等来实现画面淡入、淡出遮当视线的功能; 然而在HDRP中在OnPostRender下的GL绘制不会正常显示,要把“SteamVR_Fade”脚本原来普通方式放在 OnRenderObject 方法中调用GL来绘制的部分放到 UnityEngine.Rendering.RenderPipelineManager.endFrameRendering 这个方法回调中。 protected void OnCameraRender(ScriptableRenderContext context, Camera[] cameraList) { foreach (var camera in cameraList) { DrawLines();...
Unity使用SteamVR2.0实现基本功能(瞬移,抓取物品,射线点击,UI交互等)_unity steamvr ui交互_贪小心的博客-CSDN博客
把SteamVR的Player预制件拖到一个空场景,删掉场景内原本的相机 新建一个Plane,当做地板 找到SteamVR的人物瞬移控制器 Teleporting ,把它拖到场景里 1. 范围移动 我们需要在可以移动的区域,也就是碰撞器上,挂TeleportArea脚本 这个脚本会自动修改你的材质球 locked 该区域是否可以移动 markerActive 区域跟随按键显示隐藏 因为这个脚本会更改材质球的属性,所以我们不能直接给地板挂这个脚本 新建一个Plane,给它改名字TeleportArea 给TeleportArea对象挂TeleportArea脚本 将TeleportArea对象调整到合适位置和合适大小 现在运行项目,已经可以通过Teleport瞬移到挂载TeleportArea脚本的区域了 如果我们不想要TeleportArea生成的边框显示出来,那么就把MeshRenderer关掉就好了 2.
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with using
Contact using, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack