public void SetUiHealth(float value) { if (!uiBarInitialized) { UiProgressBar = Instantiate(ProgressBarPrefab, STF.UiManager.UiProgressBarHolder); UiProgressBar.Init(transform); UiProgressBar.SetProgress(0); UiProgressBar.SetActive(true); uiBarInitialized = true; } UiProgressBar.SetProgress(value); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); SpriteFont font = Content.Load <SpriteFont>("file"); UiProgressBar progressbar = new UiProgressBar(this, new Vector2(0, 200), 51, font); UiTextbox textbox = new UiTextbox(this, new Vector2(0, -100), font); UiRadio radio = new UiRadio(this, new Vector2(0, -200), "hejsan", font); UiCheckBox box = new UiCheckBox(this, new Vector2(0, 0), "textbox visible", font); UiButton btn = new UiButton(this, new Vector2(0, 100), "Hej", font, delegate(object sender, EventArgs args) { progressbar.Procent += (MoveUp ? 2 : -3); switch (progressbar.Procent) { case 100: MoveUp = false; break; case 0: MoveUp = true; break; } if (box.IsChecked) { textbox.IsVisible = false; } else { textbox.IsVisible = true; } }); Menu1 = new Menu(); Menu1.Add(btn); Menu1.Add(textbox); Menu1.Add(radio); Menu1.Add(box); Menu1.Add(progressbar); }