Unity3D for iOS: AR Flyer/Poster Example with Basic Sound Spectrum Analyzer

Here’s a quick Unity3D Augmented Reality example I made this week using Qualcomm’s free Vuforia for iOS plugin.

In addition to Vuforia, I used the handy open source iTween library & Unity’s AudioListener.GetSpectrumData on a dummy model I made using Blender. The 3 robots are acting as the sound spectrum analyzer, each being tweened in response to a float (decimal) that’s put together from an average from a sound frequency range.

I used a Creative Commons graffiti image from Flickr in the flyer/poster background & a Creative Commons mp3 from SoundCloud.

In this case the entire flyer/poster acts as the Image Target. I was surprised to see that it got a 5 star rating in the Target Management System (TMS) on QDevNet (TMS shows up under My Trackables after you create an account).

Unity3D for iOS: UIToolkit Not Compatible with iTween

UITookit is pretty cool, it’s FREE and it improves performance on mobile devices. However, one thing to be aware of is that UIToolkit doesn’t play nice with iTween. There are some potential hacks mentioned on the forums but those don’t sound pretty & there doesn’t seem to be any examples/source code available for those hacks.

iTween requires an instance of GameObject as it’s animation target. Trying to tween a UITextInstance or casting it to a GameObject doesn’t work:

var textToolkit:UIToolkit;
var textToolkit2:UIToolkit;
var buttonToolkit:UIToolkit;
var txt1:UITextInstance;
var txt2:UITextInstance;


iTween.MoveBy(txt1, iTween.Hash("y", y, "easeType", "easeInOutExpo", "delay", .1));	
			Assets/Scripts/mainMenuScript.js(54,22): BCE0023: No appropriate version of 'iTween.MoveBy' for the argument list '(UITextInstance, System.Collections.Hashtable)' was found.

iTween.MoveBy( txt1 as GameObject, iTween.Hash("y", y, "easeType", "easeInOutExpo", "delay", .1));	
			NullReferenceException: Object reference not set to an instance of an object
			iTween.Launch (UnityEngine.GameObject target, System.Collections.Hashtable args) (at Assets/Plugins/iTween.cs:6740)
			iTween.MoveBy (UnityEngine.GameObject target, System.Collections.Hashtable args) (at Assets/Plugins/iTween.cs:1832)
			mainMenuScript.Start () (at Assets/Scripts/mainMenuScript.js:54)

UIToolkit has it’s own basic animation engine but it doesn’t support Robert Penner’s open source easing equations out of the box. Looks like it’s partially possible to manually add some of those to the code but not all.

Haven’t yet tried this:

Make the UI / UIToolkit objects children of a GameObject in the Hierarchy. Then try to animate the GameObject & see if it’s children follow.