SteamVR Developer Hardware

SteamVR Developer Hardware

Ely 19 Jul, 2016 @ 1:29pm
I keep getting a "The type or namespace name 'SteamVR_Controller' could not be found (are you missing a using directive or an assembly reference?)" error when I try to define my two motion controllers (with Unity). Why is this?
So I keep getting this error "The type or namespace name 'SteamVR_Controller' could not be found (are you missing a using directive or an assembly reference?)". Particularly on these two lines...

private SteamVR_Controller.Device rightDevice;
private SteamVR_Controller.Device leftDevice;

I made sure to add *using Valve.VR;* at the top of my script/class. The weird thing is I've had no issue using the code above before in other scripts but now in this script in particular it doesn't want to work. What am I doing wrong here?

The script in full (or here with nicer formatting: http://hastebin.com/ledokabuza.cs ):

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Valve.VR;


/// MouseLook rotates the transform based on the mouse delta.
/// Minimum and Maximum values can be used to constrain the possible rotation

/// To make an FPS style character:
/// - Create a capsule.
/// - Add the MouseLook script to the capsule.
/// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
/// - Add FPSInputController script to the capsule
/// -> A CharacterMotor and a CharacterController component will be automatically added.

/// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
/// - Add a MouseLook script to the camera.
/// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour {

private SteamVR_Controller.Device rightDevice;
private SteamVR_Controller.Device leftDevice;

public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;

public float minimumX = -360F;
public float maximumX = 360F;

public float minimumY = -60F;
public float maximumY = 60F;

float rotationY = 0F;

void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;

rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);

transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);

transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}

void Start ()
{
// Make the rigid body not change rotation
if (GetComponent<Rigidbody>())
GetComponent<Rigidbody>().freezeRotation = true;
}
}
Last edited by Ely; 19 Jul, 2016 @ 1:30pm
< >
Showing 1-6 of 6 comments
Lehgassteenicker 20 Jul, 2016 @ 10:25am 
The type SteamVR_Controller is defined in a script "SteamVR/Scripts/SteamVR_Controller", not in Valve.VR.
Last edited by Lehgassteenicker; 20 Jul, 2016 @ 10:26am
Ely 21 Jul, 2016 @ 2:18pm 
Originally posted by Lehgassteenicker:
The type SteamVR_Controller is defined in a script "SteamVR/Scripts/SteamVR_Controller", not in Valve.VR.
Ok... Well how could I fix this issue than?
aaron.leiby  [developer] 21 Jul, 2016 @ 4:07pm 
SteamVR_Controller is not in a namespace, so it should just work. Usually when you run into reference issues like this it's due to compile order. See here for more info:
http://docs.unity3d.com/540/Documentation/Manual/ScriptCompileOrderFolders.html
Kyle 21 Jul, 2016 @ 5:21pm 
Resolved here: https://www.reddit.com/r/Unity3D/comments/4tny5f/i_keep_getting_a_the_type_or_namespace_name/

Was related to compile order of scripts in Unity, where this MouseLook script was being compiled before the SteamVR scripts, so it couldn't find the reference.
Ely 21 Jul, 2016 @ 7:20pm 
Originally posted by aaron.leiby:
SteamVR_Controller is not in a namespace, so it should just work. Usually when you run into reference issues like this it's due to compile order. See here for more info:
http://docs.unity3d.com/540/Documentation/Manual/ScriptCompileOrderFolders.html
That was it. Thanks :).
Ugurtan 17 May, 2018 @ 2:54am 
Hey Guy I have the same problem in 2018. I tried to move steam vr folder to plugins streaming assets but no luck. Is there anyone else experiencing it with unity 2018 and know how to solve this?
< >
Showing 1-6 of 6 comments
Per page: 1530 50

Date Posted: 19 Jul, 2016 @ 1:29pm
Posts: 6