Basic VR with Unity primitives SteamVR and HTC Vive
Mac Big Sur OS BUG workaround Download this 2019.4.17 scene, move the folder to your Desktop or working area. This file is already setup with SteamVR and the SteamVR Emulator. https://classes.dma.ucla.edu/Winter21/156/projects/generic2.zip Rename the folder to a new project name. Start the Unity Hub Select ADD Locate your renamed project folder Click on the project to start Mac errors: Do not Move any files to the trash, answer preferably Open or Cancel a lot Save the scene Quit Unity Mac: Open System Preferences->Security & Privacy Go to General tab Unlock the lock with your password Click Allow Anyway for any SteamVR apps listed, keep this running, there may be more files to fix. Restart the Unity Hub Open the project
Start Unity Hub SKIP this section if you used BIG SUR workaround, go to Add some primitives. (You may need to set up an account) Make sure you are using Unity 2019.4.17f1 Go to Installs
Go to Projects Select New, hold down the arrow to select 2019.4.17f1 Project Name Give your project a name such as A_Primitive_Tutorial. This will create a folder with folders inside. Location Save to the Desktop or your external drive. Select 3D. Select CREATE Select Allow access to the Firewall pop-up, if this message appears.
Make sure the main view is the Scene tab.
Add some primitives The nice thing about primitives is the collision boundaries are already set up.
Choose GameObject->3D Object->Cube etc. We will use the cube for the floor
 Hand moves the view, Move Tool, Rotate Tool, Scale Tool, Rectangle Select,and the 'Move Rotate Scale' Tool.
Select the cube to be used for the floor. Look at the Inspector tab on the right, Scale should be around 15, .1, 15 x,y,z for the floor cube. (You might need to switch from Services to Inspector.) Set Position to 0, -.05, 0 You can re-name the floor in the Inspector tab. Set Cast Shadows to Off in the Inspector.
Add more primitive shapes, place them above the floor.
Add some materials Select Assets->Create->Material. Double click the material in Assets below. Change the Albedo color in the Inspector on the right. Drag and drop the material onto the primitive while in Scene Mode
Scene View Camera Use the Alt key left mouse to tumble the camera. Alt right mouse to zoom.
Click an axis such as X in with the XYZ axis to look down the X axis. You can toggle between Persp, Iso and 2D by clicking on the word below the axis.

F for Frame Select an object, hit f The camera will adjust the clipping planes and zoom in on the object. You may notice some objects gradually disappearing, use f to adjust this.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Import plugin, Steam VR Camera and Controllers for VR This is already done if you downloaded the Big Sur workaround. Choose the Asset Store tab next to the Scene window tab If the Asset Store says you are offline, sign out and then back in to your Unity account Type SteamVR in the search bar
 Select the SteamVR Plugin by Valve (It is free) If you have never done this select Download first, then Import
Choose Import in the store window
The Import Unity package window will pop-up Scroll down to Longbow Uncheck Longbow (This will speed up the process, the file will be much smaller.) Close up the section by clicking on the down arrow.  Scroll down to Samples Uncheck Samples Select Import Choose Accept All if there is a SteamVR error messages about Resizeable Window.
Plugins always import into the Assets folder of your project. You can always copy or delete the SteamVR folders between projects.
Put the main view window back to Scene instead of Asset Store
Select the SteamVR folder from the Project tab Select the arrow , open InteractionSystem , open Core , select Prefabs Drag the Player into the Hierarchy tab

SteamVR Camera Settings This is already done if you downloaded the Big Sur workaround. Simulation Camera: Open the arrow next to Player in the Hierarchy  Open the arrow next to NoSteamVRFallbackObjects  Select FallbackObjects Change Position in Y to 0 Change Field of View to 90 (default 60)
Grab and drop the Game tab below the Scene tab to create a split view.
Select Player from the Hierarchy to position and rotate the SteamVR camera. You will see the result in the Game tab
Setup the Main Camera to be out of the way This is already done if you downloaded the Big Sur workaround. Select the Main Camera from the Hierarchy tab In the Inspector tab: Uncheck Audio Listener Change Target Display to Display 2 Change Target Eye to None in the Inspector tab (The main camera interferes with SteamVR.)
Try your Project in Sim mode Hit the Play button to stop and start your game. 
If you are running in Sim mode use w a s d, q r or the arrow buttons to navigate around the scene, and the right mouse to rotate the camera. Left mouse for interactions.
Ignore this error, this means you do not have a VR headset connected.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Throwable Objects This tool came with SteamVR. Create a cube, GameObject->3D Object->Cube
Select the cube, use Add Component button located in the Inspector at the bottom. search for throw select Throwable
Under Interactable Script in the Inspector Turn off Highlight on Hover
Hit Play and throw your object, view this in the Game tab.
Add Velocity Select the cube, use Add Component search for vel select VelocityEstimator
Hit Play
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Add a Physics Material to make the objects bouncy Select the Assets->Create->Physic Material from the menu. Give the material a name. Select the Physic Material Change Bounciness to .4 in the Inspector
Select the object you would like to adjust the bounciness: In the Inspector tab, under Collider, assign the Material

Hit Play, try adjusting the bounciness.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Import a new Skybox Choose the Asset Store tab next to the Scene window Type skybox in the search bar, Select Free Assets select Download and Import
Put the main view window back to Scene
Choose Window->Rendering->Lighting Settings Click the to change the Skybox Material to the skybox you imported. You can also make your own.
AllSkyFree Skybox BUG Work around for AllSkyFree skybox BUG, webGL will not publish These will not publish because of a script error
Select the AllSkyFree folder from the Project tab Select the arrow next to AllSkyFree Delete AllSkyFree_Menu.cs from the Assets window
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Solid Color Background if you do not want to use a Skybox Main Camera: Choose Window->Rendering->Lighting Settings Click the next to Skybox Material select None
Scene Window and Unity interface: Select Edit->Preferences (Mac: Select Unity->Preferences) Select Colors Change the Background color
SteamVR Headset Camera: Open the arrow next to Player in the Hierarchy  Open the arrow next to SteamVRObjects  Select VRCamera Under Clear Flags change Skybox to Solid Color in the Inspector Change the Background color in the Inspector Change the Field of View to 90
Simulation Camera: Open the arrow next to Player in the Hierarchy  Open the arrow next to NoSteamVRFallbackObjects  Select FallbackObjects Under Clear Flags change Skybox to Solid Color in the Inspector Change the Background color in the Inspector
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Fix the shadows All these settings can slow down performance a little, but it is worth it. Select Edit->Project Settings Select Quality Uncheck all Levels except Ultra Change Shadow Resolution to Very High Resolution If the shadow does not appear when you make a Player Decrease Shadow distance to 40 (default 150)
Select your Directional Light Lower the Strength to make the shadows lighter, try .5 (default 1) Change Bias to .007 this will be more precise (default .05) Keep Normal Bias to .4 (default .4) Change Near Plane to .1 ( default .2)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Go to Publish WebGL Go here to publish your project to webGL.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: EXAMPLES
 https://classes.dma.ucla.edu/Winter21/156/projects/examples/A_vote_primitives_player
 https://classes.dma.ucla.edu/Winter21/156-/projects/examples/A_primitives_Brian_Pea_player

NOT USED THIS QUARTER
If the Vive VR is not working with the headset Start Steam First time use, Steam will ask you to login, you may set up an account or use the department's account: login dmaucla password UCLAdma! This login seems to hang. It should work OK if you try restarting your Unity project. Worse case reboot the computer.
Make sure the headset and controllers are connected Try wiggling the Headset. Try pressing both the round buttons on the controllers together. Make sure the hand held controllers are charged.
 Steam Status Utility will look like this if it is ready.
Reset Steam if you don't see all the icons Select the down arrow next to SteamVR  Select Devices->Reboot Vive headset There is also a menu to Run Room Setup, this should be done already
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: How to transfer Your Project Between Mac and PC Move the entire project over to the PC or Mac, keep a backup Open Unity Hub Under Projects, select ADD Select your folder Start the project from the list of Projects If it asks you to Switch Target upgrade or downgrade you must answer CONFIRM (If the versions are close enough it should work.)
A message window from SteamVR may pop up: It looks like you haven't generated actions for SteamVR Input yet. Would you like to open the SteamVR Input window? Answer Yes
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Make a stand alone Player Follow this section on a PC You will be recording the project while looking through a Vive headset on a PC.
Build your project to run on it's own without Unity
File->Save Scene your scene
Select File Build Settings... Uncheck Scenes/SampleScene if you see it Select PC, Mac & Linux stand-alone Select Build & Run Select your Target Platform such as Windows Select Build And Run Create a folder outside of your Unity project Save to the folder... wait a second
Alt F4 exits the player on a PC Command Q exits the player on a Mac (A stand alone player made on a Mac will not play on a PC.)
OBS OBS screen capture VR documentation
|