当前位置:网站首页>[vivefocus uses the wavevr plug-in to obtain handle operation events]

[vivefocus uses the wavevr plug-in to obtain handle operation events]

2022-06-13 07:04:00 The year of the Phoenix

The birth of this article

Join a new company , Take over old projects , The inevitable trouble of the program ape . unfortunately , I am just an old VR The project is stuck in how to get the handle event . I found a lot of information on the Internet , Basically not , Probably because ViveFocus The reason why the sales volume of this single handle device is not very good . Today I will tell you the method , Everyone in the province takes the same detour as me .
 Please add a picture description
Single handle equipment
 Please add a picture description

One 、 Plugins are required WaveVR

This WaveVR Plug in ,Unity The mall has a free version , Download and import directly , The reason for mentioning here is , There are many people who like to play online disk resources , What I want to say is that common plug-ins like this , You'd better go first Unity Mall and PakageManager Let's find out if there is , If there are, use Unity After all, its own version is the best , The optimal .
( You have to say your Unity Version does not support such a high version , I want to say that's another matter , Just suggest ) Please add a picture description
Let's get to the point

Two 、 Place the necessary prefabricated parts in the scene

 Please add a picture description
First step , The necessary prefabricated parts are placed in the scene. None of these five elements is indispensable .
WaveVR— Make sure VR visual angle
ControllerLoader—VR Basic controller ( Such as manual adjustment )
InputModuleManager— Radiographic inspection control manager
ButtonManager— Handle button effective management  Please add a picture description
WaveVRButtons— Handle button configuration list
 Please add a picture description

3、 ... and 、 The code gets the handle interaction event

Finish the above preparations , Here comes the main point :

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using wvr;// Namespace is required 

public class GamePanel : MonoBehaviour
{
    
	Text showText;
    CanvasGroup group;
    private void Awake()
    {
    
  		// Because it is finally packaged as Android for glasses , So ordinary printing is not enough ,
    	// It's best to generate one Text Components , After the interactive button , Display the content inside 
        showText = transform.Find("ShowText").GetComponent<Text>();
        // control UI Interface display and concealment 
        group = transform.GetComponent<CanvasGroup>();
    }

    void Start()
    {
    

    }

    
    private void Update()
    {
    
    	// Judge whether there is a precast body in the scene , Avoid misplacing the times 
        if (WaveVR_ButtonManager.Instance == null)
            return;
		// Big disc press 
        bool pressedTouchpad = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Dominant).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Touchpad);
        if (pressedTouchpad)
        {
    
            showText.text = " Press Touchpad!!!";
            group.alpha = 1;
        }

		// Press the wrench key 
        bool pressedTrigger = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Dominant).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Trigger);
        if (pressedTrigger)
        {
    
            showText.text = " Press Trigger!!!";
            group.alpha = 0;
        }
		// Press... On the disc 
        bool pressedUp = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Dominant).GetPressDown(WVR_InputId.WVR_InputId_Alias1_DPad_Up);
        if (pressedUp)
        {
    
            showText.text = " Press Up!!!";
        }
		// Press the big round key in the middle , The one with a horizontal line 
        bool pressedMenu = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Dominant).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Menu);
        if (pressedMenu)
        {
    
            showText.text = " Press Menu!!!";
        }
		// Volume key + Press down 
        bool pressedVolume_Up = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Dominant).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Volume_Up);
        if (pressedVolume_Up)
        {
    
            showText.text = " Press Volume_Up!!!";
        }
    }
}

Conclusion

Binggo~, It's that simple !!!
Originality is not easy. , Share the pitfalls in the development process !!!
If it can help you , Welcome to thumb up !!!
If you have any questions, please read the message !!!
Love between brother and sister , Can you give me a compliment !!!

原网站

版权声明
本文为[The year of the Phoenix]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130701444900.html