using UnityEngine; using System.Collections; public class CarGUI : MonoBehaviour { private Car _car; private VerticalProgressBar _pedalBar; // Use this for initialization void Start () { _car = GetComponent (); _pedalBar = new VerticalProgressBar (); } // Update is called once per frame void Update () { } void OnGUI(){ if (_car != null) { var pedals = _car.Pedals; Vector2 topLeft = new Vector2(100,400); Vector2 size = new Vector2(30,200); float margin = 10; for(int i = 0; i < pedals.Length; ++i){ var pedal = (CarPedal)i; if(pedals != null && pedals.Length > i && pedals[i] != null){ _pedalBar.Value = pedals[i]; _pedalBar.OnGUI(new Rect(topLeft.x + (size.x + margin) * i,topLeft.y,size.x,size.y)); } } } } }