I need to retreive the score value from this script
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TriggerZone : MonoBehaviour {
public Text MyText;
public int score;
// Use this for initialization
void Start () {
MyText.text = "";
}
// Update is called once per frame
void Update () {
MyText.text = "$" + score;
}
void OnTriggerEnter(Collider coll) {
if (coll.CompareTag ("Pickable")){
score = score + 1;
}
if (coll.CompareTag ("Pickable")) {
Destroy (coll.gameObject);
}
}
}
So that this script…
using UnityEngine;
using System.Collections;
public class CountDownTimer : MonoBehaviour {
public int score;
float timeRemaining = 3;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
timeRemaining -= Time.deltaTime;
}
void OnGUI(){
if (timeRemaining > 0) {
GUI.Label(new Rect(100, 100, 200, 100), "Time Remaining: "+(int)timeRemaining);
}
else{
score = GetComponent<score>();
GUI.Label(new Rect(100, 100, 200, 100), "Times up your score was" + score);
//Application.LoadLevel("Testing Grounds");
}
}
}
…can use it. However I keep getting the error “CountDownTimer.score' is a
field’ but a `type’ was expected”. What do I do?
Also if anyone could help me with this I would be grateful.