一、VR中的UI交互
实现效果:
手柄碰到要交互的UI,按下Trigger,执行UI上的方法
实现步骤:
1、新建Canvas,Render Mode改为World Space,缩放0.003,分辨率3
2、新建Button(需有Button组件),Button添加boxcollider、UIElement
3、执行的方法放到UIElement上
二、手柄按键高亮、按键文字提示
1、效果展示
2、代码控制
using UnityEngine;
using Valve.VR.InteractionSystem;
public class gameObjectManager : MonoBehaviour
{
public void ShowHints(Hand hand)
{
//高亮显示手柄按钮
ControllerButtonHints.ShowButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_Grip); //两侧按键
ControllerButtonHints.ShowButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad); //圆盘键
ControllerButtonHints.ShowButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_ApplicationMenu); //菜单键
//显示文本信息
ControllerButtonHints.ShowTextHint(hand, Valve.VR.EVRButtonId.k_EButton_Grip, "换弹夹");
}
public void HideHints(Hand hand)
{
//单个隐藏手柄高亮按键
ControllerButtonHints.HideButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_Grip);
//全部隐藏
ControllerButtonHints.HideAllButtonHints(hand);
ControllerButtonHints.HideTextHint(hand, Valve.VR.EVRButtonId.k_EButton_Grip);
ControllerButtonHints.HideAllTextHints(hand);
}
}
3、手柄交互颜色控制
即调整手柄交互时,轮廓的颜色。
调整方式如下:
————————————————
版权声明:本文为优快云博主「橙哥Skode」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/weixin_38239050/article/details/81292994