Hello everyone i want to show the score when map changed here is my full script ;
using UnityEngine;
using System.Collections;
public class Fuel : MonoBehaviour {
public GUIStyle penguin1;
public GUIStyle penguin2;
public GUIStyle penguin3;
public GUIStyle penguin4;
public GUIStyle penguin5;
public float fuel = 20;
private int score = 0;
void Update() {
fuel -= 1 * Time.deltaTime;
if (fuel < 0) {
}
if (fuel > 40 ) {
fuel = 40;
}
if (fuel < -2) {
Application.LoadLevel("gameOver");
}
print (fuel);
}
void OnGUI () {
if (fuel >= 30 && fuel <= 40)
GUI.Box (new Rect (60,18,65,45), "" , penguin1);
if (fuel >= 20 && fuel <= 30)
GUI.Box (new Rect (60,18,65,45), "" , penguin2);
if (fuel >= 10 && fuel <= 20)
GUI.Box (new Rect (60,18,65,45), "" , penguin3);
if (fuel >= 0 && fuel <= 10)
GUI.Box (new Rect (60,18,65,45), "" , penguin4);
if (fuel < 0)
GUI.Box (new Rect (60,18,65,45), "" , penguin5);
if (Application.loadedLevelName == "gameOver") {
}
}
void OnTriggerEnter (Collider other) {
fuel +=8;
score +=1;
}
void OnTriggerExit (Collider other) {
Destroy(other.gameObject);
}
}
When map changed to gameOver i want to show the score is it possible with gui ?
Thanks…
Thanks for answer i did the first part but in the second part when i create a new script and paste your code it gives me error ; "Expression denotes a
– Xaintype', where avariable',value' ormethod group' was expected."Oh i fixed it. It's supposed to be (new Rect (10, 10, 100, 20) Thanks for answer :)
– Xainno problem :)
– Jeric-Miana