How do I add my style to the gui in the bottom?
Here’s the script:
#pragma strict
var reloadSound: AudioClip;
var fireSound: AudioClip;
var bullet : GameObject;
var bulletsPerSecond = 14.0;
private var shooting = false;
var bulletForce = 1000.0;
var bulletsInMag = 30;
var magsLeft = 10;
private var reloading = false;
var reloadCount = 0;
var otherObj : GameObject;
var style : GUIStyle; //Here's the style
function Start() {
InvokeRepeating("Shoot", 0.0, 1.0 / bulletsPerSecond);
}
function Shoot() {
if (!shooting) return;
var go = Instantiate(bullet, transform.position, transform.rotation);
go.rigidbody.AddRelativeForce(Vector3.up * bulletForce);
audio.PlayOneShot(fireSound);
bulletsInMag--;
}
function Update(){
shooting = false;
Debug.Log(bulletsInMag);
if(Input.GetAxis("Fire1") && bulletsInMag > 0 && !reloading){
shooting = true;
}else if(bulletsInMag <= 0){
shooting = false;
Reload();
}
}
function Reload(){
reloading = true;
otherObj.animation.Play("Reload");
audio.PlayOneShot(reloadSound);
bulletsInMag = 30;
yield WaitForSeconds(2.0);
reloading = false;
}
function OnGUI(){ //I want the style here in these 2
GUI.Box (Rect (Screen.width - 200,Screen.height-35,200,80), bulletsInMag.ToString(), "Ammo");
GUI.Label (Rect (Screen.width - 200,Screen.height-70,270,180), magsLeft.ToString(), "Ammo");
}