VR中的UI

14 篇文章 1 订阅
12 篇文章 0 订阅
VR中UI的出现场景
  • 菜单
  • 游戏元素UI,如血条、生命值、剩余时间
  • 对话框
  • 提示信息
  • 十字光标
VR中的UI一般构建步骤
  1. 新建Canvas
  2. Render Model改为World Space
  3. 修改缩放
  4. 修改Dynamic Pixel Per Unit
  5. 添加相关元素
Interaction System 中的UI交互
  • 按钮点击基于Collider,一般放置为BoxCollider;
  • UIElement类:在Interaction system中实现UI的交互,必须挂载此脚本已标记可交互的UI;
  • 按钮一般事件为OnHandClick,手柄点击Trigger键激活;
  • ControllerButtonHints类,调用一系列静态方法实现按钮高亮和文字提示。
示例:构建交互按钮,实现手柄文字提示和按钮高亮
![这里写图片描述](https://img-blog.csdn.net/20180722142454405?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3hpYW9rdW56aGFuZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR.InteractionSystem;

public class GameManager : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }

    public void ShowHits(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,"画线");
        ControllerButtonHints.ShowTextHint(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad, "选择颜色");
    }
    public void HideHits(Hand hand)
    {
        ControllerButtonHints.HideButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_Grip);
        ControllerButtonHints.HideButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad);
        ControllerButtonHints.HideButtonHint(hand, Valve.VR.EVRButtonId.k_EButton_ApplicationMenu);
        ControllerButtonHints.HideAllTextHints(hand);
    }
}
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值