为什么 unity steamvr ui插件打开 在特别远的地方

6A资讯站 >网游>正文
valve为linux推出steamvr系统 为更多硬件打开大门
在今天以前,如果你是一位pc用户,并希望享受沉浸式vr娱乐体验,那么可选择的操作系统只有windows一个。但现在这个情况有所改变,valve兑现了2016年的承诺,正式对外为linux操作系统推出steamvr系统。valve已经将linux开发版steamvr系统发布在开源项目网站github上。这是一个开发版本。它旨在让开发者开始为linux平台创建steamvr内容。目前只提供有限的硬件支持,并需要预发行的驱动程序。valve表示,目前仅在最新steamvr的beta版本提供linux支持。所以,请确保你选择了steam客户端的公开测试版,否则steamvr将因为缺少依赖项而无法运行。在显卡支持方面,据了解,linux版steamvr构建在vulkan api之上,需要最新的vulkan驱动程序。英伟达显卡需要nvidiadeveloper beta
driver375.27.10版本。英伟达驱动程序支持直接模式,这意味着头显不会显示在桌面上。amd显卡需要一个预发布版本的radv驱动程序。但目前不支持直接模式,因此hmd显示器必须在扩展模式下放置在桌面上,并且在使用vr时须禁用系统合成器。linux版steamvr目前不支持intel显卡。如果你想测试linux版本,你可能还需要注意usb设备的驱动。steamvr需要能够访问htcvive的usb设备,但大多数linux发行版在默认情况下都不支持。但你可以安装官方提供的最新版本(1.0.0.54)steam软件包来处理该问题,启用usb支持。linux openvr的开发需要unity5.6版本,但目前linux上仅支持vulkan渲染器。如果你使用的是unitysteamvr插件,需要从unityasset store下载最新的插件,因为旧版本的插件不支持linux。值得注意的是,linux版steamvr系统目前还不完善。除了上面提到的,valve表示目前还存在以下已知问题:opengl应用程序目前太慢,无法交互使用。只有vulkan submit路径最佳。不支持控制面板中的桌面视图 。目前没有实现基站的电源管理 。现在未实现头显音频设备切换 功能。vr状态窗口当前不能识别直接模式是否已经被启用,因此不应使用“enable direct mode(启用直接模式)”和“disable direct
mode(禁用直接模式)”按钮。在支持的情况,直接模式会自动启用。
您看完后的心情是
实时热点换一换
最强王者:
评分:8.3分佳作
1183人关注
最强王者:
评分:9.5分神作
最强王者:
评分:6.8分一般
最强王者:
评分:6.5分一般
最强王者:
评分:9.0分神作
最强王者:
评分:7.5分良品
微软加入vr open标准组openxr 大家怎么看呢?
粤网文[-284号
游戏健康忠告:抵制不良游戏
拒绝盗版游戏
注意自我保护
谨防受骗上当
适度游戏益脑
沉迷游戏伤身
合理安排时间
享受健康生活推荐这篇日记的豆列
&&&&&&&&&&&&
&(2人关注)Topic Details
steamvr1.2.1与unity5.3.5是否兼容?
使用5.3.5版本unity的时候碰到了一些问题,在我安插其他插件时会出现找不到steamve,controller的报错。重新开启项目的时候也会出现BUG汇报
Showing - of
Showing - of
Topic Details
Date Posted: 4 Jun @ 7:39pmPosts: 0
More discussions
Report this post
Note: This is ONLY to be used to report spam, advertising, and problematic (harassment, fighting, or rude) posts.
View mobile websiteSteamVR Plgins的使用(一)-爱编程
SteamVR Plgins的使用(一)
本章节主要讲解使用SteamVR&Plugins插件为基础,来介绍Vive开发的入门,重点讲解设备的激活和控制接口。SteamVR&Plugins在unity官方资源商店可以免费下载,这里我就不给出链接了。
导入SteamVR&Plugins后,不要在他的示例上去做开发,那样你会走弯路。因为这个插件的设备初始化代码很怪异,甚至可以说无法使用。因此我们需要自己写设备的初始化代码以及设备的操作接口。
我们对原插件进行封装后就可以愉快的使用了,之后怎么开发就和这个设备无关了,我们开发这类的应用无非是获取相关的接口操作。
新建场景,然后在Camera上添加组件SteamVR_Camera,然后点击&Expand&按钮,之后我们就得到了一个基本的VR相机。
然后我们在Camera的下面新建两个GameObject,并命名为LeftHand和RightHand。同时添加组件SteamVR_TrackedObject。然后在各自的下面添加一个对象名为Mode,并绑定组件SteamVR_RenderModel。
如果对这些步骤有疑问,可以查看百度文库按照上面的操作完成基本的对象搭建操作:/view/eaaec2f058fb770bf68a55b1.html
接下来就是开始撸代码了,新建脚本SteamVR_InitManager.cs,来获取手柄的激活和相关的初始化代码。
using UnityE
using System.C
using Valve.VR;
public class SteamVR_InitManager : MonoBehaviour
public event Action&SteamVR_TrackedObject& OnLeftDeviceA//左手柄激活事件
public event Action&SteamVR_TrackedObject& OnRightDeviceA//右手柄激活事件
public SteamVR_TrackedObject LeftO
public SteamVR_TrackedObject RightO
private bool[] isAllC//0代表右手状态,1代表左手状态
private uint leftIndex = 100;//左手柄对应的设备ID
private uint rightIndex = 100;//右手柄对应的设备ID
private static SteamVR_InitM
public DeviceInput LeftHandI
public DeviceInput RightHandI
public static SteamVR_InitManager Instance {
if (instance == null) {
instance = GameObject.FindObjectOfType&SteamVR_InitManager&();
// Use this for initialization
void Awake()
LeftObject = transform.FindChild("LeftHand").GetComponent&SteamVR_TrackedObject&();
RightObject = transform.FindChild("RightHand").GetComponent&SteamVR_TrackedObject&();
LeftObject.gameObject.SetActive(false);
RightObject.gameObject.SetActive(false);
void Start()
StartCoroutine(CheckDeviceActive());
void OnEnable()
OnLeftDeviceActive += LeftDeviceA
OnRightDeviceActive += RightDeviceA
void OnDisable()
OnLeftDeviceActive -= LeftDeviceA
OnRightDeviceActive -= RightDeviceA
/// &summary&
/// 检测手柄设备是否激活
/// &/summary&
/// &returns&&/returns&
IEnumerator CheckDeviceActive()
yield return new WaitForSeconds(1);
while (!isAllConnect[0] || !isAllConnect[1])
for (uint i = 1; i & OpenVR.k_unMaxTrackedDeviceC i++)
if (i == leftIndex || i == rightIndex)//已经初始化的不再进入判断
if (OpenVR.System != null && OpenVR.System.IsTrackedDeviceConnected(i))
OnDeviceConnected(new object[] { i, true });
yield return new WaitForFixedUpdate();
yield return 0;
/// &summary&
/// 检测激活的设备是否是手柄
/// &/summary&
/// &param name="args"&&/param&
private void OnDeviceConnected(object[] args)
if (args != null && args.Length & 1)
uint index = (uint)args[0];
bool isConnect = (bool)args[1];
var system = OpenVR.S
if (isConnect && system != null && system.GetTrackedDeviceClass(index) == ETrackedDeviceClass.Controller)
uint tmpleftIndex = (uint)system.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
uint tmprightIndex = (uint)system.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.RightHand);
if (index == tmprightIndex)
isAllConnect[0] =
rightIndex =
OnRightDeviceActive(RightObject);
else if (index == tmpleftIndex)
isAllConnect[1] =
leftIndex =
OnLeftDeviceActive(LeftObject);
private void RightDeviceActive(SteamVR_TrackedObject obj)
DeviceActive(obj, rightIndex);
RightHandInput = obj.GetComponent&DeviceInput&();
private void LeftDeviceActive(SteamVR_TrackedObject obj)
DeviceActive(obj, leftIndex);
LeftHandInput = obj.GetComponent&DeviceInput&();
/// &summary&
/// 匹配对应的设备号,完成手柄模型的设置
/// &/summary&
/// &param name="device"&&/param&
/// &param name="index"&&/param&
void DeviceActive(SteamVR_TrackedObject device, uint index)
SteamVR_TrackedObject.EIndex eIndex = (SteamVR_TrackedObject.EIndex)Enum.Parse(typeof(SteamVR_TrackedObject.EIndex), "Device" + index);
device.index = eI
device.GetComponentInChildren&SteamVR_RenderModel&().index = eI
device.gameObject.SetActive(true);
然后就是大家比较关心的手柄控制接口代码DeviceInput.cs,我基本上把所有的手柄控制事件都写完了.
using UnityE
using System.C
using Valve.VR;
public class DeviceInput : MonoBehaviour {
//Swipe directions
public enum SwipeDirection
public event Action OnPressT
//按住扳机键
public event Action OnPressDownT
// 按下扳机键
public event Action OnPressUpT
//抬起扳机键
public event Action OnTouchP
//按住触摸板
public event Action OnPressDownGripB
//按下侧键
public event Action OnPressDownMenuB
//按下菜单键
public event Action&Vector2& OnBeginT
//触摸触摸板的位置
public event Action&Vector2& OnEndT//抬起触摸板的位置
public event Action OnTouchPadD
//按下触摸板
public event Action OnTouchPadUp;//抬起触摸板
public event Action&SwipeDirection& OnPadS
[SerializeField]
private float m_SwipeWidth = 0.6f;
//The width of a swipe
private Vector2 m_PadDownP
private float m_LastHorizontalV
private float m_LastVerticalV
private SteamVR_TrackedObject H
private SteamVR_Controller.D
private Vector2 m_PadP
public void Start()
Hand = GetComponent&SteamVR_TrackedObject&();
public void Update()
CheckInput();
private void CheckInput()
// Set the default swipe to be none.
SwipeDirection swipe = SwipeDirection.NONE;
if (device == null)
device = SteamVR_Controller.Input((int)Hand.index);
print("NUll Device");
if (device.GetPress(EVRButtonId.k_EButton_SteamVR_Trigger))
if (OnPressTrigger != null) OnPressTrigger();
if (device.GetPressDown(EVRButtonId.k_EButton_SteamVR_Trigger))
if (OnPressDownTrigger != null) OnPressDownTrigger();
if (device.GetPressUp(EVRButtonId.k_EButton_SteamVR_Trigger))
if (OnPressUpTrigger != null) OnPressUpTrigger();
if (device.GetTouch(EVRButtonId.k_EButton_SteamVR_Touchpad))
if (OnTouchPad != null) OnTouchPad();
m_PadPosition = device.GetAxis();
if (device.GetTouchUp(EVRButtonId.k_EButton_SteamVR_Touchpad))
if (OnTouchPadUp != null) OnTouchPadUp();
if (OnEndTouch != null) OnEndTouch(m_PadPosition);
swipe = DetectSwipe();
m_PadDownPosition = Vector2.
if (device.GetTouchDown(EVRButtonId.k_EButton_SteamVR_Touchpad))
if (OnTouchPadDown != null) OnTouchPadDown();
if (OnBeginTouch != null) OnBeginTouch(m_PadDownPosition = device.GetAxis());
if (device.GetPressDown(EVRButtonId.k_EButton_Grip))
if (OnPressDownGripButton != null) { OnPressDownGripButton(); }
if (device.GetPressDown(EVRButtonId.k_EButton_ApplicationMenu))
if (OnPressDownMenuButton != null) OnPressDownMenuButton();
if (swipe != SwipeDirection.NONE)
OnPadSwipe(swipe);
if (device.GetTouch(EVRButtonId.k_EButton_SteamVR_Touchpad))
m_PadPosition = device.GetAxis();
m_PadDownPosition = Vector2.
private SwipeDirection DetectSwipe()
Vector2 swipeData = (m_PadPosition - m_PadDownPosition).
bool swipeIsVertical = Mathf.Abs(swipeData.y) & m_SwipeW
bool swipeIsHorizontal = Mathf.Abs(swipeData.x) & m_SwipeW
if (swipeData.y & 0f && swipeIsVertical)
return SwipeDirection.UP;
if (swipeData.y & 0f && swipeIsVertical)
return SwipeDirection.DOWN;
if (swipeData.x & 0f && swipeIsHorizontal)
return SwipeDirection.RIGHT;
if (swipeData.x & 0f && swipeIsHorizontal)
return SwipeDirection.LEFT;
return SwipeDirection.NONE;
public void OnDisEnable()
OnPressTrigger =
//按住扳机键
OnPressDownTrigger =
// 按下扳机键
OnPressUpTrigger =
//抬起扳机键
OnTouchPad =
//按住触摸板
OnPressDownGripButton =
//按下侧键
OnPressDownMenuButton =
//按下菜单键
OnBeginTouch =
//触摸触摸板的位置
OnEndTouch =//抬起触摸板的位置
OnTouchPadDown =
//按下触摸板
OnTouchPadUp =//抬起触摸板
OnPadSwipe =
OK,接下来写一个简单的测试类来测试相关的代码:
using UnityE
using System.C
/// &summary&
/// 这是一个测试类,简单的测试了手柄的激活以及部分手柄的操作事件
/// 两个手柄分开注册,这样扩展性非常好,相同的按键可以做不同的处理
/// 大家可以补充测试
/// &/summary&
public class TestEvent : MonoBehaviour {
void OnEnable() {
SteamVR_InitManager.Instance.OnLeftDeviceActive += OnLeftDeviceA//左手柄激活
SteamVR_InitManager.Instance.OnRightDeviceActive += OnRightDeviceA//右手柄激活
private void OnRightDeviceActive(SteamVR_TrackedObject obj)
print("OnRightDeviceActive"+obj);
SteamVR_InitManager.Instance.RightHandInput.OnPressDownTrigger += OnPressDownT
SteamVR_InitManager.Instance.RightHandInput.OnTouchPadDown += OnTouchPadD
private void OnPressDownTrigger()
print("OnPressDownTrigger");
private void OnTouchPadDown()
print("OnTouchPadDown");
private void OnLeftDeviceActive(SteamVR_TrackedObject obj)
print("OnLeftDeviceActive" + obj);
SteamVR_InitManager.Instance.LeftHandInput.OnPressDownTrigger += OnPressDownT
SteamVR_InitManager.Instance.LeftHandInput.OnTouchPadDown += OnTouchPadD
void OnDisable() {
SteamVR_InitManager.Instance.OnLeftDeviceActive -= OnLeftDeviceA//左手柄激活
SteamVR_InitManager.Instance.OnRightDeviceActive -= OnRightDeviceA//右手柄激活
  下一章我主要介绍手柄和射线事件的相结合代码,以及抛物线的绘制和移动,欢迎大家关注
版权所有 爱编程 (C) Copyright 2012. . All Rights Reserved.
闽ICP备号-3
微信扫一扫关注爱编程,每天为您推送一篇经典技术文章。

我要回帖

更多关于 unity3d steamvr 的文章

 

随机推荐