• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by eulyx · Sep 28, 2018 at 04:51 PM · assemblydefinition

Error CS1061 type Valve.VR.SteamVR_Render - Got code from another project?

Hi, I am at a university PC and found some nice features in a very simple VR Game from a friend. I took exactly the same settings and so on, cause I would like to implement it... but I am getting this error I do not understand.

Error in Unity: Assets/Scripts/SteamVR_Controller.cs(68,72): error CS1061: Type 'Valve.VR.SteamVR_Render' does not contain a definition for 'trackingSpace' and no extension method 'trackingSpace' of type 'Valve.VR.SteamVR_Render'could be found. Are you missing an assembly reference?

The Code //======= Copyright (c) Valve Corporation, All rights reserved. =============== // // Purpose: Wrapper for working with SteamVR controller input // // Example usage: // // var deviceIndex = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost); // if (deviceIndex != -1 && SteamVR_Controller.Input(deviceIndex).GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) // SteamVR_Controller.Input(deviceIndex).TriggerHapticPulse(1000); // //=============================================================================

 using UnityEngine;
 using Valve.VR;
 
 public class SteamVR_Controller
 {
     public class ButtonMask
     {
         public const ulong System            = (1ul << (int)EVRButtonId.k_EButton_System); // reserved
         public const ulong ApplicationMenu    = (1ul << (int)EVRButtonId.k_EButton_ApplicationMenu);
         public const ulong Grip                = (1ul << (int)EVRButtonId.k_EButton_Grip);
         public const ulong Axis0            = (1ul << (int)EVRButtonId.k_EButton_Axis0);
         public const ulong Axis1            = (1ul << (int)EVRButtonId.k_EButton_Axis1);
         public const ulong Axis2            = (1ul << (int)EVRButtonId.k_EButton_Axis2);
         public const ulong Axis3            = (1ul << (int)EVRButtonId.k_EButton_Axis3);
         public const ulong Axis4            = (1ul << (int)EVRButtonId.k_EButton_Axis4);
         public const ulong Touchpad            = (1ul << (int)EVRButtonId.k_EButton_SteamVR_Touchpad);
         public const ulong Trigger            = (1ul << (int)EVRButtonId.k_EButton_SteamVR_Trigger);
     }
 
     public class Device
     {
         public Device(uint i) { index = i; }
         public uint index { get; private set; }
 
         public bool valid { get; private set; }
         public bool connected { get { Update(); return pose.bDeviceIsConnected; } }
         public bool hasTracking { get { Update(); return pose.bPoseIsValid; } }
 
         public bool outOfRange { get { Update(); return pose.eTrackingResult == ETrackingResult.Running_OutOfRange || pose.eTrackingResult == ETrackingResult.Calibrating_OutOfRange; } }
         public bool calibrating { get { Update(); return pose.eTrackingResult == ETrackingResult.Calibrating_InProgress || pose.eTrackingResult == ETrackingResult.Calibrating_OutOfRange; } }
         public bool uninitialized { get { Update(); return pose.eTrackingResult == ETrackingResult.Uninitialized; } }
 
         // These values are only accurate for the last controller state change (e.g. trigger release), and by definition, will always lag behind
         // the predicted visual poses that drive SteamVR_TrackedObjects since they are sync'd to the input timestamp that caused them to update.
         public SteamVR_Utils.RigidTransform transform { get { Update(); return new SteamVR_Utils.RigidTransform(pose.mDeviceToAbsoluteTracking); } }
         public Vector3 velocity { get { Update(); return new Vector3(pose.vVelocity.v0, pose.vVelocity.v1, -pose.vVelocity.v2); } }
         public Vector3 angularVelocity { get { Update(); return new Vector3(-pose.vAngularVelocity.v0, -pose.vAngularVelocity.v1, pose.vAngularVelocity.v2); } }
 
         public VRControllerState_t GetState() { Update(); return state; }
         public VRControllerState_t GetPrevState() { Update(); return prevState; }
         public TrackedDevicePose_t GetPose() { Update(); return pose; }
 
         VRControllerState_t state, prevState;
         TrackedDevicePose_t pose;
         int prevFrameCount = -1;
         public void Update()
         {
             if (Time.frameCount != prevFrameCount)
             {
                 prevFrameCount = Time.frameCount;
                 prevState = state;
 
                 var system = OpenVR.System;
                 if (system != null)
                 {
                     valid = system.GetControllerStateWithPose(SteamVR_Render.instance.trackingSpace, index, ref state, (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t)), ref pose);
                     UpdateHairTrigger();
                 }
             }
         }
 
         public bool GetPress(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) != 0; }
         public bool GetPressDown(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) != 0 && (prevState.ulButtonPressed & buttonMask) == 0; }
         public bool GetPressUp(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) == 0 && (prevState.ulButtonPressed & buttonMask) != 0; }
 
         public bool GetPress(EVRButtonId buttonId) { return GetPress(1ul << (int)buttonId); }
         public bool GetPressDown(EVRButtonId buttonId) { return GetPressDown(1ul << (int)buttonId); }
         public bool GetPressUp(EVRButtonId buttonId) { return GetPressUp(1ul << (int)buttonId); }
 
         public bool GetTouch(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) != 0; }
         public bool GetTouchDown(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) != 0 && (prevState.ulButtonTouched & buttonMask) == 0; }
         public bool GetTouchUp(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) == 0 && (prevState.ulButtonTouched & buttonMask) != 0; }
 
         public bool GetTouch(EVRButtonId buttonId) { return GetTouch(1ul << (int)buttonId); }
         public bool GetTouchDown(EVRButtonId buttonId) { return GetTouchDown(1ul << (int)buttonId); }
         public bool GetTouchUp(EVRButtonId buttonId) { return GetTouchUp(1ul << (int)buttonId); }
 
         public Vector2 GetAxis(EVRButtonId buttonId = EVRButtonId.k_EButton_SteamVR_Touchpad)
         {
             Update();
             var axisId = (uint)buttonId - (uint)EVRButtonId.k_EButton_Axis0;
             switch (axisId)
             {
                 case 0: return new Vector2(state.rAxis0.x, state.rAxis0.y);
                 case 1: return new Vector2(state.rAxis1.x, state.rAxis1.y);
                 case 2: return new Vector2(state.rAxis2.x, state.rAxis2.y);
                 case 3: return new Vector2(state.rAxis3.x, state.rAxis3.y);
                 case 4: return new Vector2(state.rAxis4.x, state.rAxis4.y);
             }
             return Vector2.zero;
         }
 
         public void TriggerHapticPulse(ushort durationMicroSec = 500, EVRButtonId buttonId = EVRButtonId.k_EButton_SteamVR_Touchpad)
         {
             var system = OpenVR.System;
             if (system != null)
             {
                 var axisId = (uint)buttonId - (uint)EVRButtonId.k_EButton_Axis0;
                 system.TriggerHapticPulse(index, axisId, (char)durationMicroSec);
             }
         }
 
         public float hairTriggerDelta = 0.1f; // amount trigger must be pulled or released to change state
         float hairTriggerLimit;
         bool hairTriggerState, hairTriggerPrevState;
         void UpdateHairTrigger()
         {
             hairTriggerPrevState = hairTriggerState;
             var value = state.rAxis1.x; // trigger
             if (hairTriggerState)
             {
                 if (value < hairTriggerLimit - hairTriggerDelta || value <= 0.0f)
                     hairTriggerState = false;
             }
             else
             {
                 if (value > hairTriggerLimit + hairTriggerDelta || value >= 1.0f)
                     hairTriggerState = true;
             }
             hairTriggerLimit = hairTriggerState ? Mathf.Max(hairTriggerLimit, value) : Mathf.Min(hairTriggerLimit, value);
         }
 
         public bool GetHairTrigger() { Update(); return hairTriggerState; }
         public bool GetHairTriggerDown() { Update(); return hairTriggerState && !hairTriggerPrevState; }
         public bool GetHairTriggerUp() { Update(); return !hairTriggerState && hairTriggerPrevState; }
     }
 
     private static Device[] devices;
 
     public static Device Input(int deviceIndex)
     {
         if (devices == null)
         {
             devices = new Device[OpenVR.k_unMaxTrackedDeviceCount];
             for (uint i = 0; i < devices.Length; i++)
                 devices[i] = new Device(i);
         }
 
         return devices[deviceIndex];
     }
 
     public static void Update()
     {
         for (int i = 0; i < OpenVR.k_unMaxTrackedDeviceCount; i++)
             Input(i).Update();
     }
 
     // This helper can be used in a variety of ways.  Beware that indices may change
     // as new devices are dynamically added or removed, controllers are physically
     // swapped between hands, arms crossed, etc.
     public enum DeviceRelation
     {
         First,
         // radially
         Leftmost,
         Rightmost,
         // distance - also see vr.hmd.GetSortedTrackedDeviceIndicesOfClass
         FarthestLeft,
         FarthestRight,
     }
     public static int GetDeviceIndex(DeviceRelation relation,
         ETrackedDeviceClass deviceClass = ETrackedDeviceClass.Controller,
         int relativeTo = (int)OpenVR.k_unTrackedDeviceIndex_Hmd) // use -1 for absolute tracking space
     {
         var result = -1;
 
         var invXform = ((uint)relativeTo < OpenVR.k_unMaxTrackedDeviceCount) ?
             Input(relativeTo).transform.GetInverse() : SteamVR_Utils.RigidTransform.identity;
 
         var system = OpenVR.System;
         if (system == null)
             return result;
 
         var best = -float.MaxValue;
         for (int i = 0; i < OpenVR.k_unMaxTrackedDeviceCount; i++)
         {
             if (i == relativeTo || system.GetTrackedDeviceClass((uint)i) != deviceClass)
                 continue;
 
             var device = Input(i);
             if (!device.connected)
                 continue;
 
             if (relation == DeviceRelation.First)
                 return i;
 
             float score;
 
             var pos = invXform * device.transform.pos;
             if (relation == DeviceRelation.FarthestRight)
             {
                 score = pos.x;
             }
             else if (relation == DeviceRelation.FarthestLeft)
             {
                 score = -pos.x;
             }
             else
             {
                 var dir = new Vector3(pos.x, 0.0f, pos.z).normalized;
                 var dot = Vector3.Dot(dir, Vector3.forward);
                 var cross = Vector3.Cross(dir, Vector3.forward);
                 if (relation == DeviceRelation.Leftmost)
                 {
                     score = (cross.y > 0.0f) ? 2.0f - dot : dot;
                 }
                 else
                 {
                     score = (cross.y < 0.0f) ? 2.0f - dot : dot;
                 }
             }
             
             if (score > best)
             {
                 result = i;
                 best = score;
             }
         }
 
         return result;
     }
 }
 
 

Any Ideas? I am a beginner.... but this should work cause it is from VR Steam, right?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mastodontfilm · Dec 09, 2018 at 08:41 PM 0
Share

I am also getting this error. Does someone know how to solve it?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

151 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Test Runner --> unable to reference my code from the test 2 Answers

Visual studio cannot find references to dlls from custom assembly definitions 2 Answers

Segfault 11 on unity's Macho x86_64 executable file, what compiler and assembler does unity use for this specific case? 0 Answers

My projects can't find each other in Visual Studio 0 Answers

This is weird - Assembly hi could not be loaded 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges