Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Virtual Reality VR in Unity VR Setup VR Camera Setup

Code

When I go to code it has errors saying that the VRDevice is obselute and has been moved and renamed how do I fix?

1 Answer

Quinton Gordon
Quinton Gordon
10,985 Points

Unity has deprecated the UnityEngine.VR namespace used in these videos. Instead of VRDevice you need to add the following namespace:

using UnityEngine.XR;

and then use XRDevice like so:

if(!XRDevice.isPresent)

The change in namespace is documented in the Unity manual here:

Unity Manual: XR

and the scripting API is documented here:

Unity Scripting API: XRDevice

You do not need to have the VR namespace mentioned in the video unless you are using Unity 5.6 or lower as it has been completely depreciated and replaced by the XR namespace. Going forward keep in mind that VR development is moving at breakneck speeds so the official Unity docs are going to be your friend when stuff does not work like shown in the videos.