- Home /
This question was
closed Feb 18, 2014 at 10:41 AM by
Benproductions1 for the following reason:
Duplicate Question
Object Reference not set to an Instance
using UnityEngine;
using System.Collections;
public class QuestionClass2 : MonoBehaviour
{
public Question[] arrayOfQuestions;
public Question currentQuestion;
public bool showQuestion = true;
private int coinToss;
public bool Heads;
public bool Tails;
public class Question
{
private string questionText;
private Rect questionRect;
private string[] answers = new string[4];
private string[] displayAnswers = new string[4];
private Rect[] answerRects = new Rect[4];
private string correctAnswer;
private Rect correctRect;
public int correctAnswerIndex;
private int questionWidth = 300;
private int answerWidth = 75;
private int questionHeight = 1000;
private int correctWidth = 500;
public int selectedAnswer = -1;
void Update()
{
//currentQuestion.selectedAnswer = 0;
if(currentQuestion.selectedAnswer == currentQuestion.correctAnswerIndex)
>>>>>>>>> getting an error here{
ChooseRandomQuestion(); // Picks a random question
}
}
}
Ive attached a script to a empty gameobject, Do i need reference that gameobject ?
Comment
something like this gameObject.GetComponent().currentQuestion;
public QuestionClass2 test = GameObject.FindWithTag("Question$$anonymous$$anager").GetComponent<QuestionClass2>();
on this line, i get error Expecting ";", but its there
You can only use compile time values for default variables. This question has been asked many, many times before. I've even answered a couple. I'm sure you can find many of those thorough your preffered search-engine.