"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Augmented Reality - Make GameObject touchable

I am developing an iPad-based augmented reality app.  I am struggling with how to make my GameObjects touchable.  I've looked all around forums and some YouTube tutorials but nothing seems to work out.  

This is my hierarchy (also attached as screenshot below).

ARCamera--CameraImageTarget--CubeImageTarget--Cube

I have two C# scripts: touchableManager (attached to ARCamera) and touchableGameObject (attached Cube and Cube).

touchableManager code:

using UnityEngine;using System.Collections;using System.Collections.Generic;public class touchableManager : MonoBehaviour{    public LayerMask touchInputMask;    private List<GameObject> touchList = new List<GameObject>();    private GameObject[] touchesOld;    private RaycastHit hit;    void Update ()     {        if (Input.touchCount > 0)        {            touchesOld = new GameObject[touchList.Count];            touchList.CopyTo(touchesOld);            touchList.Clear();            foreach (Touch touch in Input.touches)            {                Ray ray = GetComponent<Camera>().ScreenPointToRay (touch.position);    //attached the main camera                if (Physics.Raycast(ray, out hit, 100f, touchInputMask.value))                {                    GameObject recipient = hit.transform.gameObject;                    touchList.Add(recipient);                    if (touch.phase == TouchPhase.Began) {                        recipient.SendMessage ("onTouchDown", hit.point, SendMessageOptions.DontRequireReceiver);                    }                    if (touch.phase == TouchPhase.Ended) {                        recipient.SendMessage ("onTouchUp", hit.point, SendMessageOptions.DontRequireReceiver);                    }                    if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved) {                        recipient.SendMessage ("onTouchStay", hit.point, SendMessageOptions.DontRequireReceiver);                    }                    if (touch.phase == TouchPhase.Canceled) {                        recipient.SendMessage ("onTouchExit", hit.point, SendMessageOptions.DontRequireReceiver);                    }                }            }            foreach (GameObject g in touchesOld)            {                if (!touchList.Contains(g))                 {                    g.SendMessage("onTouchExit", hit.point, SendMessageOptions.DontRequireReceiver);                }            }        }    }}

 

touchableGameObject code

using UnityEngine;using UnityEngine;using System.Collections;public class touchableGameobject : MonoBehaviour{    public Color defaultColor;    public Color selectedColor;    private Material mat;        void Start()    {        mat = GetComponent<Renderer>().material;    }        void onTouchDown()    {        mat.color = selectedColor;    }        void onTouchUp()    {        mat.color = defaultColor;    }        void onTouchStay()    {        mat.color = selectedColor;    }        void onTouchExit()    {        mat.color = defaultColor;    }}

 

I've attached a screenshot of my hierarchy along with the result so far.  I am able to get my two GameObjects to appear over the AR markers.  However, I am unable to touch them and trigger my color changes.  Nothing happens.  Please, any help is greatly appreciated.

Attachment