private void CreateAndUpdateBar(KeyValuePair <string, float> dataPair) { var progressBar = FindBar(dataPair.Key); var progressBarBarSize = new Vector2((float)Math.Floor(dataPair.Value / MaxValue * RectSize.x), RectSize.y); if (progressBar != null) { progressBar.BarSize = progressBarBarSize; } else { progressBar = (IconProgressBar)iconProgressBarScene.Instance(); progressBar.Name = dataPair.Key; AddChild(progressBar); SubBars.Add(progressBar); progressBar.Color = BarHelper.GetBarColour(SelectedType, dataPair.Key, IsProduction); progressBar.HighlightColor = new Color(progressBar.Color.r + 0.5f, progressBar.Color.g + 0.5f, progressBar.Color.b + 0.5f, 0.3f); progressBar.BarSize = progressBarBarSize; progressBar.IconTexture = BarHelper.GetBarIcon(SelectedType, dataPair.Key); progressBar.IconModulation = BarHelper.GetBarIconColor(SelectedType); progressBar.MouseFilter = MouseFilterEnum.Pass; progressBar.Connect("gui_input", this, nameof(BarToggled), new Array { progressBar }); progressBar.Connect("mouse_entered", this, nameof(OnBarMouseOver), new Array { progressBar }); progressBar.Connect("mouse_exited", this, nameof(OnBarMouseExit), new Array { progressBar }); } }