- Home /
Question by
LuigiRulz324 · Apr 29, 2018 at 11:22 PM ·
textprogrammingimagebuttonsbutton trigger events
Creating a Jeopardy style game, script's not working.
Ok so I'm creating a simple jeopardy style game and I've decided that each square on the grid will be a button with the $ amount on it. I need the button to bring up the question, an image, and two or more buttons for the correct and incorrect answers as well as deactivate its self.
I know nothing about coding but this is I've managed to cobble together. I really need help on this.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class QuestionScript : MonoBehaviour
{
public GameObject Question1Button; //A Button
public GameObject IncorrectAnswer; //A Button
public GameObject CorrectAnswer; //A Button
public GameObject QuestionBackground; //Image brought up to make the question readable over the grid
public Text Question1Text; //Text Object
// Use this for initialization
void Start()
{
Question1Text.gameObject.SetActive(false);
IncorrectAnswer.gameObject.SetActive(false);
CorrectAnswer.gameObject.SetActive(false);
}
// Update is called once per frame
public void Update()
{
}
public void QuestionAsking()
{
//Player Selects $ Amount
if (Input.GetMouseButtonDown(0))
{
Question1Button.gameObject.SetActive(false); //Deactivates $ Button
Question1Text.gameObject.SetActive(true); //Displays Text Object with Question Written
IncorrectAnswer.gameObject.SetActive(true); //Displays the Button with the Incorrect Answer
CorrectAnswer.gameObject.SetActive(true); //Displays the Button with the Correct Answer
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Button Action Triggering Multiple Times Per Click? 1 Answer
Buttons don't trigger only in build 0 Answers