Reputation: 31
I created a panel for showing some text according to image recognized using vuforia in unity. So when detected image targets are changed, the text should change according to that image target. I need c# code for that. Please help!
I already tried a code using elseif function, but it is not stable and it doesn't work as expected.
public class DataControllerCS002 : MonoBehaviour
{
private DefaultTrackableEventHandler target;
public Text winText;
public GameObject EndPanel;
// Use this for initialization
void Start()
{
target = GetComponent<DefaultTrackableEventHandler>();
winText.text = "SCAN QRCODE";
EndPanel.SetActive(false);
}
// Update is called once per frame
void Update()
{
if (target.liveobject == "qr1")
{
winText.text = "Walk Straight";
}
else if (target.liveobject == "qr1left2")
{
winText.text = "Walk Straight";
}
else if (target.liveobject == "left1")
{
winText.text = "Walk Straight";
}
else if (target.liveobject == "qrright1")
{
winText.text = "Walk Straight";
}
else if (target.liveobject == "qrright2")
{
winText.text = "Walk Straight";
}
else if (target.liveobject == "qrcenter")
{
winText.text = "Walk Left";
}
}
}
Upvotes: 0
Views: 134
Reputation: 44
I wouldn't do this in update
function, but rather in event where target.liveobject
value is changing. Do that there and you should be good to go.
Upvotes: 1