I am trying a animation with AR using unity and Metaio sdk. I have to play that animation step by step when I try the below script it works perfect on ipad and android mobile device.
Variable declaration
********************
public GUIStyle buttonTextStyle;
public Texture aTexture;
private int curretnStep=1;
GameObject gameObject;
float SizeFactor;
Texture2D texture;
Animator CMTD42M ;
bool isplaystarted = false;
int[] videolengtharray = new int[6];
int CurrentFrame=0;
bool islocked = false;
*************
if (GUIUtilities.ButtonWithText (new Rect (Screen.width - 160, Screen.height - 100, 160, 100), "Next", null, buttonTextStyle)) {
CMTD42M.speed=1;
switch (curretnStep) {
case 1:
CMTD42M.Play ("First");
break;
case 2:
CMTD42M.Play ("Second");
break;
case 3:
CMTD42M.Play ("Third");
break;
case 4:
CMTD42M.Play ("Four");
break;
case 5:
CMTD42M.Play ("Five");
break;
case 6:
CMTD42M.Play ("Six");
break;
}
curretnStep++;
//isplaystarted = true;
}
As I am running this script on Epson Moverio(Glasses) it dont take the button click event,so I used onMouseButtonDown As below script:-
if (Input.GetMouseButtonDown (0)) {
if ((new Rect (Screen.width - 160, Screen.height - 100, 160, 100)).Contains (Event.current.mousePosition))
{
CMTD42M.speed=1;
switch (curretnStep) {
case 1:
CMTD42M.Play ("First");
break;
case 2:
CMTD42M.Play ("Second");
break;
case 3:
CMTD42M.Play ("Third");
break;
case 4:
CMTD42M.Play ("Four");
break;
case 5:
CMTD42M.Play ("Five");
break;
case 6:
CMTD42M.Play ("Six");
break;
}
curretnStep++;
}
}
the animation is not playing step by step. it plays in different order..
Can ANybody help me, or please guide where I made mistake. I am new in Unity and AR developement
I get that Mouse-event proper. Is the problem in animation or in mouse click.. Please help..
Thanks bl0z0, I have written this code in OnGUI() function.
I finally solve my problem.. I am not getting the reason behind it.
The problem was in variable current step, when I do
curretnStep++;
it was incremented by 2,not by 1.(only in Epson Moverio) so it was not taking proper switch-cases and animation plays wrong.