- Home /
How do I make my GUI a different texture?
I want to make my 'Lives : 5' custom with my own font/texture. Here is my script. What do I need to add? Noob! Btw this is with C#.
using UnityEngine;
using System.Collections;
public class PlayerStatusController : MonoBehaviour {
public int Lives = 5;
public ParticleEmitter EnemyExplosionEffect;
public void OnGUI() {
GUI.Label(new Rect(20, 20, 100, 20), System.String.Format("LIVES: {0}" , Lives));
}
public void OnTriggerEnter(Collider collider) {
Lives--;
Vector3 enemy_position = collider.transform.position;
Destroy(collider.gameObject);
ParticleEmitter explosion = (ParticleEmitter)Instantiate(EnemyExplosionEffect, enemy_position,Quaternion.identity);
explosion.Emit();
Vector3 explosionPos = transform.position;
Collider[] colliders = Physics.OverlapSphere(explosionPos, 5.0f);
foreach (Collider hit in colliders) {
if (!hit) {
continue;
}
if (hit.rigidbody) {
hit.rigidbody.AddExplosionForce(500.0f, explosionPos, 5.0f);
if (Lives == 0) {
Application.LoadLevel ("GameOver");
if (Lives == 0) {
Screen.lockCursor = false;
}
}
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Losing references made in editor script 1 Answer
C# GetComponent Issue 2 Answers
Grabing and moving a box(C#) 3 Answers