- Home /
Click gameObject and then pop up window
Player click on a gameObject and then pop upwindow.So basically after player click on the gameObject, it will show a list of options. Only one option is correct. I would need to do some checking. For example, button 1 , button 2 and button3, button 1 is the correct option out of the three. How can i do the checking?
Initially the gameObject is disabled (invisible), after the correct answer (button1) is clicked, i want the gameObject to be enabled (visible). GameObject.Find("rad01aa").active = true; // i try using this but it does not appear it when the button is clicked.
Please split this into multiple questions. It's difficult to answer, otherwise.
Also, have you heard of the 'if-statement'? That first question of yours is very simple, so I'm a little worried about how useful any advice I can give you would be.
Hi syclamoth, both question 1 and 2 is interlink so i cant split it. Only the third questions are irrelevant. i will do the editing.
Yes, i heard of if-statement. What i am confused it to detect click object then display the list of option. When the correct option is selected, the gameobject will be enabled(visible) to player. http://imageshack.us/photo/my-images/716/door000.png/
From the images, the player have to click on the box(the one with dotted line), then it will display a list of option. If correct option is selected, display the gameobject that are disable in the beginning. So player have to click two boxes and click on the available option as shown in the picture. So would like to ask how can i go about doing it?
Answer by DeathHawk · Mar 13, 2012 at 06:08 PM
If your using GUI its really easy if not then get the mouse coordinates on the screen and create a collision box over the buttons you want pressed. When mouse coordinates X and Y are inside of the collision box for button 1 and mouse left button is clicked then button 1 bool = true. After button 1 bool = true if button one is the correct answer the have a bool for correct answer and when that equals true then make the stuff happen that you want to have happen.
Hi DeathHawk, look at the picture, I was thinking how about i create an empty button on the box(dotted line). Like that it is easier for me . So basically, the player click the button(the one on the box with dotted line), then it will display the popup window. Regarding the check the correct answer, i still have no clue how to check the answer.
Come on, it's just an if-statement!
if(GUILayout.Button("Wrong Answer"))
{
answeredCorrectly = false;
}
if(GUILayout.Button("Right Answer"))
{
answeredCorrectly = true;
}
I really don't see what is so complicated about this.
Thank you. I will give it a try. How about the question on making the gameobject reappear again? it is using gameObject.enabled = true;
if you want to use gameObject.enabled, then put a script on the object:
if(answeredCorrectly){ gameObject.enabled = true; }
var r01aa: GameObject;
if(options == true) print("active r01aa"); r01aa.renderer.enabled = true;
i try to do it this way but it doesn't work properly.