[unity] Pico VR unity development notes (1)

Pico VR Development Notes (1)

XR Interaction Tooikit Version 2.3.2

1. Environment construction

In fact, the official documentation has been written in great detail, here is just a quick build without talking nonsense, and there is another official description that is wrong, please add it, explain it in the development tools section

Plug-in installation - install pico's sdk and XR Interaction Tooikit

Environment configuration - add the headset and handle to the scene, and configure and project configuration

Development tools——The streaming development tools provided by Pico can be debugged using handles and headsets without packaging.

1. Plug-in installation

pico SDK installation

pico SDK download address: SDK - PICO Developer Platform (pico-interactive.com)

Unzip the SDK after downloading

Open unity→Window→PackgeManager→Add Package From disk (upper left corner +)→select package.json in the decompressed file

XR Interaction Tooikit Installation

Search XR Interaction Tooikit in packageManager

Select the version as high as possible, not lower than 2.1.0.

Open the Samples panel and import Starter Assets , **XR Device Simulator** and Tunneling Vignette .

2. Environment configuration

scene configuration

Add XR Origin : Hierarchy→Add (upper left corner +)→XR→XR Origin(VR)

handle settings

  1. Select the XR Origin sub-object LeftHand Controller of the Hierarchy

  2. Configure the XR Controller of the LeftHand Controller, click the preset in the upper right corner, and select XRI Default Left Controller (the right handle is also configured, select XRI Default Right Controller)

  3. Select the handle model, select LeftControllerModel(Tranform) in the Model Prefab of XR Controller

packaging settings

Select: Edit→Player→settings for Android→other Setting

Minimum API Level select Android 10.0

Target API Level 选择Automatic(Highest installed)

Scripting Backend select IL2CPP

Tick ​​ARM64

Select: Edit→Project Settings→XR Plug-in Management→Android Standalone Settings→Select PICO

3. Development tools

SDK installation

Download link: SDK - PICO Developer Platform (PICO Unity Live Preview Plugin)

Unzip the SDK after downloading

Open unity→Window→PackgeManager→Add Package From disk (upper left corner +)→select package.json in the decompressed file

windows download client

Download link: SDK - PICO Developer Center (PICO Developer Center)

The steam streaming tool will be installed after the local installation

Enable developer mode for all-in-one

  1. Turn on the PICO VR all-in-one machine.
  2. Head to Settings > General .
  3. Ray-point the Settings field and tap multiple times until Developer Options appears below the left navigation bar.
  4. Click Developer to enter the developer options interface.
  5. Turn on the USB debugging switch in the upper right corner .

*The official document here is wrong, you need to click the setting button multiple times to open the developer model

project settings

Select: Edit→Project Settings→XR Plug-in Management→ PC Standalone Settings→Select PICO Live Preview

2. Development

1. Handle input

get the handle

    InputDevice deviceLeft;//左手柄
    InputDevice deviceRight;//右手柄
    private void Start()
    {
        deviceLeft = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
        deviceRight = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
    }

The handle triggers the core method TryGetFeatureValue

handle trigger trigger

    /// <summary>
    /// 扳机键
    /// </summary>
    /// <param name="inputDevice">手柄</param>
    /// <param name="action">触发委托</param>
    /// <param name="Value">触发参数</param>
    void triggerButton(InputDevice inputDevice, ref bool Value, Action action)
    {
        if (inputDevice.TryGetFeatureValue(CommonUsages.triggerButton,out Value)&&Value)
        {
            action();
        }
    }

Trigger key force

    /// <summary>
    /// 扳机键力度
    /// </summary>
    /// <param name="inputDevice">手柄</param>
    /// <param name="action">触发委托</param>
    /// <param name="Value">触发参数</param>
    void trigger(InputDevice inputDevice, ref float Value, Action<float> action)
    {
        if (inputDevice.TryGetFeatureValue(CommonUsages.trigger, out Value)&& !Value.Equals(0))
        {
            action(Value);
        }
    }

grab key

    /// <summary>
    /// 抓握键
    /// </summary>
    /// <param name="inputDevice"></param>
    /// <param name="action"></param>
    /// <param name="Value"></param>
    void gripButton(InputDevice inputDevice, ref bool Value, Action action)
    {
        if (inputDevice.TryGetFeatureValue(CommonUsages.gripButton, out Value) && Value)
        {
            action();
        }
    }

Grip key strength

    /// <summary>
    /// 抓握键力度
    /// </summary>
    /// <param name="inputDevice"></param>
    /// <param name="action"></param>
    /// <param name="Value"></param>
    void grip(InputDevice inputDevice, ref float Value, Action<float> action)
    {
        if (inputDevice.TryGetFeatureValue(CommonUsages.grip, out Value) && !Value.Equals(0))
        {
            action(Value);
        }
    }

joystick direction

    /// <summary>
    /// 摇杆方向
    /// </summary>
    /// <param name="inputDevice"></param>
    /// <param name="action"></param>
    /// <param name="Value"></param>
    void primary2DAxis(InputDevice inputDevice, ref Vector2 Value, Action<Vector2> action)
    {
        if (inputDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Value) && !Value.Equals(Vector2.zero))
        {
            action(Value);
        }
    }

joystick

    /// <summary>
    /// 摇杆
    /// </summary>
    /// <param name="inputDevice"></param>
    /// <param name="Value"></param>
    /// <param name="action"></param>
    void primary2DAxisClick(InputDevice inputDevice, ref bool Value, Action action)
    {
        if (inputDevice.TryGetFeatureValue(CommonUsages.primary2DAxisClick, out Value) && Value)
        {
            action();
        }
    }

X/A

    /// <summary>
    /// X/A
    /// </summary>
    /// <param name="inputDevice"></param>
    /// <param name="Value"></param>
    /// <param name="action"></param>
    void primaryButton(InputDevice inputDevice, ref bool Value, Action action)
    {
        if (inputDevice.TryGetFeatureValue(CommonUsages.primaryButton, out Value) && Value)
        {
            action();
        }
    }

Y/B

    /// <summary>
    /// Y/B
    /// </summary>
    /// <param name="inputDevice"></param>
    /// <param name="Value"></param>
    /// <param name="action"></param>
    void secondaryButton(InputDevice inputDevice, ref bool Value, Action action)
    {
        if (inputDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out Value) && Value)
        {
            action();
        }
    }

2. Rays

way to get rays

XRRayInteractor.TryGetCurrent3DRaycastHit(out hit)

XRRayInteractoris the handle's script XRRayInteractor

Demo

    public XRRayInteractor rayInteractor;
    RaycastHit hit;
    Vector3 getRayPoint()
    {
        if (rayInteractor.TryGetCurrent3DRaycastHit(out hit))
        {
           
            string name = hit.collider.name;
            Debug.Log(name);
            return hit.point;
        }
        else
        {
            return Vector3.zero;
        }
    }

Guess you like

Origin blog.csdn.net/dxs1990/article/details/131339879