LoginSignup
0
0

More than 5 years have passed since last update.

Rennka_Memo

Posted at

error:NullReferenceException: Object reference not set to an instance of an object

error:NullReferenceException: Object reference not set to an instance of an object
Valve.VR.SteamVR_Action_Boolean.GetState (SteamVR_Input_Sources inputSource) (at Assets/SteamVR/Input/SteamVR_Action_Boolean.cs:94)

出来事

お借りしたコード:こちら

GrabTest.cs
using UnityEngine;
using Valve.VR;

public class GrabTest : MonoBehaviour
{
    public SteamVR_Input_Sources hand;
    public SteamVR_Action_Boolean grabAction;

    void Update()
    {
        if (grabAction.GetState(hand))
        {
            Debug.Log("Grab!");
        }
    }
}

このスクリプトをGameObjectにアタッチしてそのまま再生すると上記のエラーを吐く。

解決策

アタッチしたGameObjectのInspectorのGrab Test (Script)のGrab ActionをNoneから変更すると解決する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0