/* * If you like my work, and found it useful * Please donate * Bitcoin Address: 1LdyAQHXdFVqzGzah45sGKhsQ8wDE6jyci * Good luck and enjoy. * */ //goes with "ProgressBar Script for Unity (C#)" http://bitbin.it/sJiAXXCQ/ using UnityEngine; namespace Assets.Scripts { public class ProgressBarRenderer :MonoBehaviour { private ProgressBar _bar; public void Init(ProgressBar bar) { _bar = bar; } public void OnGUI() { var oldColor = GUI.color; GUI.color = _bar.BackGroundColor; GUI.DrawTexture(new Rect(_bar.Position.x, _bar.Position.y, _bar.Size.x, _bar.Size.y), GameResources.Square); GUI.color = _bar.ForeGroundColor; GUI.DrawTexture( _bar.IsVertical ? new Rect(_bar.Position.x, _bar.Position.y, _bar.Size.x,_bar.Value * _bar.Size.y/_bar.MaxValue) : new Rect(_bar.Position.x, _bar.Position.y, _bar.Value*_bar.Size.x/_bar.MaxValue, _bar.Size.y), GameResources.Square); GUI.color = oldColor; } } }