- Home /
Drop down menu trigger'd cutscene
Hi I have problem with my script or rather, I've no idea how to build it. What i'm required to do is create a drop down menu script and when a element is selected, it will play the corresponding scenes. However, my script doesn't seem to switch camera as it should. Also, if I use animation.play, the thing will loop constant because the condition (if (listEntry ==1)) stays the same. And another problem is I can't switch back to the main camera after the animation is played. Here is my script.
private var showList = false;
private var listEntry = 0; private var list : GUIContent[]; private var listStyle : GUIStyle; private var picked = false; var camera1 : Camera; var camera2 : Camera;
function Start () { // Make some content for the popup list list = new GUIContent[7]; list[0] = new GUIContent("Level 2"); list[1] = new GUIContent("Level 3"); list[2] = new GUIContent("Level 4"); list[3] = new GUIContent("Level 5"); list[4] = new GUIContent("Level 6"); list[5] = new GUIContent("Level 7"); list[6] = new GUIContent("Level 8");
// Make a GUIStyle that has a solid white hover/onHover background
to indicate highlighted items listStyle = new GUIStyle(); listStyle.normal.textColor = Color.white; var tex = new Texture2D(2, 2); var colors = new Color[4]; for (color in colors) color = Color.white; tex.SetPixels(colors); tex.Apply(); listStyle.hover.background = tex; listStyle.onHover.background = tex; listStyle.padding.left = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4; }
function OnGUI () {
if (Popup.List (Rect(1, 1, 100, 20), showList, listEntry,
GUIContent("Click me!"), list, listStyle)) { picked = true; } if (picked) { GUI.Label (Rect(1,17, 400, 20), "You picked " + list[listEntry].text + "!"); if (listEntry==1){
camera1.active=false; //main camera
camera2.active=true; //cutscene camera
WaitOn();
camera1.active=true;
camera2.active=false;
}
}
}
function WaitOn(){
yield WaitForSeconds (3);
}
Your answer
Follow this Question
Related Questions
Animations and Cut-Scenes 0 Answers
Animation end trigger 1 Answer
Created an Open Close Animation, but script wont activate both doors? 1 Answer
importing exporting Animation help. 1 Answer
Death and animations 1 Answer