Log in or register to post comments

Problem with User Defined Target

March 20, 2014 - 4:12am #1

I'm using the vuforia extension on Unity called User Defined Targets, but when i launch the sample app i have this kind of error:

NullReferenceException: Object reference not set to an instance of an object
UserDefinedTargetBuildingAbstractBehaviour.BuildNewTarget (System.String targetName, Single sceenSizeWidth)
UserDefinedTargetEventHandler.BuildNewTarget () (at Assets/Scripts/UserDefinedTargetEventHandler.cs:136)
UserDefinedTargetEventHandler.OnTappedOnNewTargetButton () (at Assets/Scripts/UserDefinedTargetEventHandler.cs:141)
UIButton.Draw () (at Assets/Scripts/UIFramework/UIButton.cs:43)
UserDefinedTargetEventHandler.Draw () (at Assets/Scripts/UserDefinedTargetEventHandler.cs:50)
UDTAppManager.Draw () (at Assets/Scripts/UDTAppManager.cs:21)
SceneViewManager.OnGUI () (at Assets/Scripts/UIFramework/SceneViewManager.cs:28)
anyone can help me?

Problem with User Defined Target

March 31, 2015 - 9:07am #8

I have a same problem in unity. but if you try to make a GUI button in sample app and if you don't make your own scene then you will not get any NullReference error.

Problem with User Defined Target

April 14, 2014 - 7:18am #7

Glad to hear that the article was helpful to solve your problem.

And, thanks, we will keep the suggestion about Video Playback vanilla example / tutorial in consideration.



Problem with User Defined Target

April 14, 2014 - 2:23am #6

Sorry, hadn't seen that yet. 

Will do and report back, thanks! 


Edit: works! 

At first I had two errors (around IEnumerable<Trackable>), but I had to change the standard using System.Collections; to using System.Collections.Generic; and add a closing } at the end of the script. 

And just to be sure, it's not unsafe/unstable or anything if I set the BuildNewTarget function to public? 


Thanks again!


P.s. if we could have a similar vanilla example of the video texture, that'd be awesome!


Problem with User Defined Target

April 14, 2014 - 1:51am #5

Check this article, which explains step by step what you need to setup UDT correctly:


try to compare your setup with the one abpve, to see if you have missed anything.


Problem with User Defined Target

April 14, 2014 - 1:46am #4



I have a similar set-up and the same issue (don't want to clog up the forums with duplicate questions). 

I'm using (or: trying to use) an NGUI button to trigger a new UDT. These are the steps I followed: 

  1. Applied the UserDefinedTargetEventHandler script from the sample to the UserDefinedTargetBuilder object. 
  2. Commented out some of the UI stuff that I don't need (e.g. Draw() and mNewUserDefinedTargetButton).
  3. Added an image target and referenced it from the UserDefinedTargetBuilder.
  4. Made the UserDefinedTargetEventHandler => BuildNewTarget() function public.
  5. Put a script on my NGUI element to call this function using public UserDefinedTargetEventHandler builder => builder.BuildNewTarget();

The nullReference error occurs on the line mTargetBuildingBehaviour.BuildNewTarget(targetNameImageTargetTemplate.GetSize().x);

Which looks like it can't find the image target? 


I've attached two screenshots of the links between the button, builder and target. 

Any help would be appreciated. 




Image icon targetBuilder.png51.57 KB
Image icon NGUIbutton.png25.11 KB

Problem with User Defined Target

March 20, 2014 - 5:10am #3

I've already seen it, but I have not been of help. is an error that appears to me as I push the button to set the new targets

Problem with User Defined Target

March 20, 2014 - 4:34am #2

Have you checked the Getting started guide?

This explains how to setup Vuforia and the samples:


Note: you need Unity 4.1 or higher (just in case).


Log in or register to post comments