0
VuforiaフレームワークでUnityに仮想ボタンを作成しようとしています。 私はこのチュートリアルに従っ: http://3dvrcentral.com/2016/09/19/how-to-augmented-reality-tutorials-virtual-buttons-with-unity-and-vuforia/C#Unity仮想ボタンの作成
私のコンソールは、すぐに私はゾンビは私のコンソールが私にこの例外を与える何かをやらせるためのコードを追加すると、ボタンが押されていると言われますけど。例外の後、私は自分のコードも投稿しました。
Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
public class vbScipt : MonoBehaviour, IVirtualButtonEventHandler {
private GameObject vbButtonObject;
private GameObject zombie;
// Use this for initialization
void Start() {
vbButtonObject = GameObject.Find ("actionButton");
zombie = GameObject.Find ("zombie");
vbButtonObject.GetComponent<VirtualButtonAbstractBehaviour>().RegisterEventHandler (this);
}
public void OnButtonPressed (VirtualButtonAbstractBehaviour vb){
Debug.Log ("Button Pressed");
zombie.GetComponent<Animation>().Play();
}
public void OnButtonReleased (VirtualButtonAbstractBehaviour vb){
Debug.Log ("Button Released");
zombie.GetComponent<Animation>().Stop();
}
}
のようなものですそれは完全な例外ですか?それはあなたが何行起こっているのかを教えてください。その部分を追加してください。あなたのスクリプトがStart()の間に "ゾンビ"を見つけられないように思えます。 – ryeMoss
コメントはコメントには長すぎるので、私は答えに再び投稿しなければなりませんでした。そして、はい、あなたは間違いがこの行にあります:zombie.GetComponent().Play();なぜか分からない。その他のチュートリアルでは、このように動作します –