By AleR3ds
on Sat, 04/26/2014 - 13:05
Hello everyone, I made this script, but it works only in part, when the target is detected the buttons appear, so everything is ok, but when I press the buttons to start the animations do not work, if I put a statement like "openurl "works, while the statement" animation.Play no!. did not understand where I'm wrong. Sorry for English Thank you so much Alessio using UnityEngine;using System.Collections; public class bottoni : MonoBehaviour, ITrackableEventHandler { private TrackableBehaviour mTrackableBehaviour; private bool mShowGUIButton = false; void Start () { mTrackableBehaviour = GetComponent<TrackableBehaviour>(); if (mTrackableBehaviour) { mTrackableBehaviour.RegisterTrackableEventHandler(this); } } public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus) { if (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED) { mShowGUIButton = true; } else { mShowGUIButton = false; } } void OnGUI () { if (mShowGUIButton) { if (GUI.Button (new Rect (10,10,110,50), "cella")) {animation.Play("cella"); }if (GUI.Button (new Rect (10,70,110,50), "orologio")) {animation.Play("orologio"); }if (GUI.Button (new Rect (10,130,110,50), "portale")) {animation.Play("portale"); }if (GUI.Button (new Rect (10,190,110,50), "EXIT")) {Application.Quit(); } } } }
GUI Button
are you attaching this script to a gameObject that actually has a Animation module?
why don't you try:
GUI Button
Hi Alexv,
Thank you, for help me, i use your script for see when i click button in console windows write Playng OK.!!
When i click button "cella" console windows print "Playng OK", but my animation don't start.
Sigh !!
Alessio