Type your code in the box. To create a new line within the box use SHIFT + ENTER. Hello,
this doesn't help me!
Please is there somebody to help me i google all day every day to fix this but no help
So this is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
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.transform.Rotate (0, 1000 * Time.deltaTime, 0);
}
public void OnButtonReleased (VirtualButtonAbstractBehaviour vb){
Debug.Log ("Button Released");
zombie.GetComponent<Animation> ().Stop ();
}
}
And i get this error:
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
at vbScipt.OnButtonPressed (Vuforia.VirtualButtonAbstractBehaviour vb) [0x00011] in /Users/denyscarlino/FutureDeck(T.V)/Assets/Scripts/vbScipt.cs:23
at Vuforia.VirtualButtonAbstractBehaviour.OnTrackerUpdated (Boolean pressed) [0x00000] in <filename unknown>:0
at Vuforia.StateManagerImpl.UpdateVirtualButtons (Int32 numVirtualButtons, IntPtr virtualButtonPtr) [0x00000] in <filename unknown>:0
at Vuforia.VuforiaManagerImpl.UpdateTrackers (FrameState frameState) [0x00000] in <filename unknown>:0
at Vuforia.VuforiaManagerImpl.Update (ScreenOrientation counterRotation, Boolean reapplyOldState) [0x00000] in <filename unknown>:0
at Vuforia.VuforiaARController.UpdateStatePrivate (Boolean forceUpdate, Boolean reapplyOldState) [0x00000] in <filename unknown>:0
at Vuforia.VuforiaARController.UpdateState (Boolean forceUpdate, Boolean reapplyOldState) [0x00000] in <filename unknown>:0
at Vuforia.DigitalEyewearARController.Update () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d0] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115
at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000b9] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:443
at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00018] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MulticastDelegate.cs:71
at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:415
at Vuforia.DelegateHelper.InvokeDelegate (System.Delegate action, System.Object[] args) [0x00000] in <filename unknown>:0
UnityEngine.Debug:LogError(Object)
Vuforia.DelegateHelper:InvokeDelegate(Delegate, Object[])
Vuforia.DelegateHelper:InvokeWithExceptionHandling(Action)
Vuforia.VuforiaAbstractBehaviour:Update()
Looks like your zombie object is null when you press the button. Make sure it exists in the scene and is being assigned to your variable properly.
Thanks,
-Vuforia Support