SteamVR2.0 UGUI ray interactive simulation
Article Directory
- SteamVR2.0 UGUI ray interactive simulation
- foreword
- 1. Preparation before starting
-
- 1. The environment should be set up before the start of the project. In the Unity project, import SteamVR into the program and directly enter the store, as shown in the figure below
- 2. Find the SteamVR prefab Player and drag it into our scene
- 3. Create a new empty object PR_VrInputmodule
- 3. Add a PointorLine empty object under the RightHand object under the Player object
- 4. Code connection
- Summarize
foreword
Since the current project is using the SteamVR2.0 version, the compatibility with VRTK is not very good, and the compatibility with other VR plug-ins is also very different. Many of the problems are caused by the Unity version. Now I am going to write a ray by hand. Interact with the ray and the UI.
提示:以下是本篇文章正文内容,下面案例可供参考
1. Preparation before starting
1. The environment should be set up before the start of the project. In the Unity project, import SteamVR into the program and directly enter the store, as shown in the figure below
2. Find the SteamVR prefab Player and drag it into our scene
3. Create a new empty object PR_VrInputmodule
The empty object PR_VrInputmodule needs the following components.
The script VRInputModule needs to be written by ourselves.
3. Add a PointorLine empty object under the RightHand object under the Player object
The empty object PointorLine component is shown below.
There is also a sub-object ball under the PointorLine object. The function of the ball is to set it at the end of the ray to simulate the top of the ray.
The script ShotLine needs us to write and add separately. The camera component must be enabled, otherwise our running screen will be affected.
3.1LineRender component settings
The specific settings are as follows.
Special attention should be paid to the setting of this place.
At the end, right click and select Edit Key to select to compile this point, and the parameters are as above.
4. Code connection
SteamVR2.0UGUI ray interactive script connection
Summarize
The whole layout can be realized as shown above, and the code can be copied according to the code in the link.