- Home /
made animation in idle state while click back
problem with the following ..... in a single scene i have some cameras... i can move between cameras by using next button.. each sub scenes having some animations , it will work by click....after finishing my animation move to next sub scene... if i will come back to the previous scene using back button the animations should be ideal...tell me the logic....also once you finished all animation then only next button should enable.... help me with the script
//camera var cam1 : Camera; var cam2 : Camera; var cam3 : Camera; var cam4 : Camera; var cam5 : Camera;
//buttons var infeed1 : Transform; var infeed2 : Transform; var infeed3 : Transform; var infeed4 : Transform;
var outfeed1 : Transform; var outfeed2 : Transform; var outfeed3 : Transform;
var powerswitch : Transform;
//GUI var cus : GUISkin;
//Textures var hmi1 : Texture; var hmi2 : Texture; var hmi3 : Texture; var hmi4 : Texture; var hmi5 : Texture; var hmi6 : Texture; var hmi7 : Texture; var hmi8 : Texture; var hmi9 : Texture;
//Animations var infeed : Animation; var outfeed : Animation; var power1 : Animation;
//variables var a1 = 0; //var a2 = 0;
function Start() {
cam1.enabled = true; cam2.enabled = false; cam3.enabled = false; cam4.enabled = false; cam5.enabled = false;
}
function OnGUI() { if(cam1.camera.enabled == true) { if(a1 == 0) {
GUI.skin = cus; GUI.Box(Rect(0,0,Screen.width,60), "Welcome to WeilerLable Lab \n Lets start by turning on the accumulation tables");
if(GUI.Button(Rect(Screen.width * 0.9 , 15,100,30), "NEXT"))
{
cam1.enabled = false;
cam2.enabled = true;
a1++;
}
}
}
if(cam2.camera.enabled == true) {
GUI.skin = cus;
GUI.Box(Rect(0,0,Screen.width,60), "This is the INFEED ACCUMULATION TABLE \n Turn each and every knob to the START positon ");
if(a1 == 1) {
if(GUI.Button(Rect(Screen.width * 0.9 , 15,100,30), "NEXT"))
{
cam2.enabled = false;
cam3.enabled = true;
a1++;
}
}
if(GUI.Button(Rect(Screen.width * 0.1/10000, 15 , 100, 30),"BACK"))
{
cam1.enabled = true;
cam2.enabled = false;
a1=1;
}
// } }
if(cam3.camera.enabled == true) {
GUI.skin = cus;
GUI.Box(Rect(0,0,Screen.width,60), "This is the OUTFEED ACCUMULATION TABLE \n Turn each and every knob to the START positon ");
if(a1 == 2)
{
if(GUI.Button(Rect(Screen.width * 0.9 , 15,100,30), "NEXT"))
{
cam3.enabled = false;
cam4.enabled = true;
a1++;
}
}
if(GUI.Button(Rect(Screen.width * 0.1/10000, 15 , 100, 30),"BACK"))
{
cam2.enabled = true;
cam3.enabled = false;
//a2++;
a1=2;
}
// }
}
if(cam4.camera.enabled == true) {
GUI.skin = cus;
GUI.Box(Rect(0,0,Screen.width,60), "Turn ON the Main POWER Switch ");
if(a1 == 3)
{
if(GUI.Button(Rect(Screen.width * 0.9 , 15,100,30), "NEXT"))
{
cam5.enabled = true;
cam4.enabled = false;
a1++;
}
}
if(GUI.Button(Rect(Screen.width * 0.1/10000, 15 , 100, 30),"BACK"))
{
cam3.enabled = true;
cam4.enabled = false;
//a2++;
a1=3;
}
// }
}
}
function Update () { if(Input.GetMouseButtonDown(0)) { var ray = camera.ScreenPointToRay(Input.mousePosition); var hit : RaycastHit;
if(Physics.Raycast(ray,hit)) {
if(cam2.camera.enabled == true && a1 == 1)
{
if(hit.transform == infeed1)
{
infeed.Play("left");
}
if(hit.transform == infeed2)
{
infeed.Play("l2");
}
if(hit.transform == infeed3)
{
infeed.Play("l3");
}
if(hit.transform == infeed4)
{
infeed.Play("right");
}
}
if(cam3.camera.enabled == true && a1 == 2)
{
if(hit.transform == outfeed1)
{
outfeed.Play("left");
}
}
if(hit.transform == powerswitch)
{
power1.Play("play");
}
}
}
}
once the scene get finished stop that particular animation using $$anonymous$$cher.Stop("Play"); once click back button play the idle animation
Your answer
Follow this Question
Related Questions
Unity 5 GUI system 1 Answer
Activating UI panel on GameObject Click/Destroy 0 Answers
Control an animation with a slider 5 Answers