Example #1
0
        public UIProgressBar(string imgBackground, string imgProgress, float x, float y)
        {
#if UNITY_EDITOR
            Name = "UIProgressBar";
#endif
            Background = gameObject.AddComponent <Image>();
            SetBackground(imgBackground);
            Background.SetNativeSize();

            Progress                  = new UIImage(imgProgress, 0, 0);
            Progress.image.type       = Image.Type.Filled;
            Progress.image.fillMethod = Image.FillMethod.Horizontal;
            this.AddChild(Progress);
            Progress.SetToCenter(CenterType.OnlyPosition);

            Head = new UINode();
            Head.SetSize(Progress.Height, Progress.Height);
            Head.y     = Progress.HarfHeight;
            Head.Pivot = Anchor.MiddleCenter;
            Progress.AddChild(Head);

            SetPosition(x, y);

            Value = 1f;
        }