VRTK3.2.1插件之UI触发 三

工具:unity 2018.2.7、VRTK3.2.1、SteamVR plugin1.1.1

1、场景目录如下,与上一篇讲抓取的文章类似,如下图:

VRTK3.2.1插件之UI触发 三

2、挂在组件如下图所示:

VRTK3.2.1插件之UI触发 三

VRTK3.2.1插件之UI触发 三

手柄挂载组件如下图所示,可以实现手柄射线触发UI交互

VRTK3.2.1插件之UI触发 三

canvas上挂在如下组件,这样它了里面的UI才能被射线出发,进行相应的交互

VRTK3.2.1插件之UI触发 三

三、此demo涉及到一小段代码,如下:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;

public class ButtonChange : MonoBehaviour {

    // Use this for initialization
    void Start() {

    }

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

    }

    public void button1() {
        //EditorSceneManager.LoadScene("MyGrab");
        SceneManager.LoadScene("MyGrab");
        
    }
    public void button2() {
        //EditorSceneManager.LoadScene("MyTeleport");
        SceneManager.LoadScene("MyTeleport");
    }

    public void button3()
    {
        //EditorSceneManager.LoadScene("");
        SceneManager.LoadScene("MyUI");
    }
}

VRTK3.2.1插件之UI触发 三

VRTK3.2.1插件之UI触发 三

本案例demo:https://download.****.net/download/hyy_sui_yuan/11025984

注意:本案例与前两篇的案例是同一个项目,只需要下载一次即可