*
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public class ScreenSpacePosition{
|
||||
public bool Relative;
|
||||
public Vector2 Position;
|
||||
public Vector2 PixelPosition{
|
||||
get{
|
||||
if(Relative){
|
||||
return new Vector2(Position.x * Screen.width, Position.y * Screen.height);
|
||||
}else{
|
||||
return Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class GunStats : MonoBehaviour {
|
||||
public ScreenSpacePosition Position;
|
||||
private Gun _gun;
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
public void SetGun(Gun gun){
|
||||
_gun = gun;
|
||||
}
|
||||
|
||||
void OnGUI(){
|
||||
if (_gun != null) {
|
||||
GUI.Label (new Rect (Position.PixelPosition.x, Position.PixelPosition.y, 100, 100), string.Format("{0}/{1}", _gun.GetLoadedAmmo(), _gun.GetAvailableAmmo()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user