I can access the object from the script however I want to directly change values of the object in the script and this is not allowing me to. Here is my scrip for the main script:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using RTS;
public class QuestionMenu : MonoBehaviour {
public struct Question{
public string questionText;
public string answer;
public string solution1;
public string solution2;
public string solution3;
}
//public void QuestionObject(string QuestionText, string answer, string solution1, string solution2, string solution3){
//Debug.Log ("lol");
//}
public Question QuestionObject = new Question();
Canvas canvas;
public UserInput Player;
public Text QuestionText;
public Text Button1;
// Use this for initialization
void Start () {
canvas = GetComponent<Canvas>();
canvas.enabled = false;
ResourceManager.QuestionMenuOpen = false;
//instruction = GetComponent<Text>();
//Debug.Log (QuestionText);
Button1.text = "Crazy";
QuestionText.text = "Yo Bro";
}
// Update is called once per frame
void Update () {
////Debug.Log (QuestionObject.questionText);
if(ResourceManager.QuestionMenuOpen == true){
//QuestionObject.questionText = "bloo";
Pause ();
//QuestionText.text = "Question 1) Differentiate 3x\u2074 + 2x.";
//Button1.text = "12x\u00B3 + 2";
}
}
public void Pause (){
canvas.enabled = true;
Player.enabled = false;
Time.timeScale = 0.0f;
Cursor.visible = true;
//QuestionObject = Questions.QuestionObject;
Debug.Log (QuestionObject.questionText);
QuestionText.text = QuestionObject.questionText;
//ResourceManager.QuestionMenuOpen = true;
}
void Resume (){
Cursor.visible = false;
canvas.enabled = false;
Player.enabled = true;
Time.timeScale = 1.0f;
ResourceManager.QuestionMenuOpen = false;
}
}
And here is the script for my script:
using UnityEngine;
using System.Collections;
public class QuestionScript : MonoBehaviour {
// Use this for initialization
void Start () {
QuestionMenu.QuestionObject.answer = "asdf";
}
// Update is called once per frame
void Update () {
}
}
Edit: I wish to access the Object QuestionObject from the scrip shown above here is a screen shot of the gameObject which has both scripts attached to it
