Ejemplo n.º 1
0
    private DistributionBar NewDistribBar(Color color, float percentageVal)
    {
        DistributionBar dBar = Instantiate(distribBarPrefab, distributionContainer);

        dBar.SetColor(color);
        // Set bar's width depending on percentage
        dBar.SetPercentageVal(percentageVal);
        float newWidth = percentageVal * distributionContainer.rect.width;

        dBar.SetDistribBarWidth(newWidth);

        return(dBar);
    }
Ejemplo n.º 2
0
 public void SetGraphProperties(string barName, float percentageVal, float width, bool prefix = false)
 {
     if (garphs.TryGetValue(barName, out RectTransform bar))
     {
         if (!barName.Contains("Dot"))
         {
             DistributionBar dBar = bar.GetComponent <DistributionBar>();
             dBar.SetPercentageVal(percentageVal, prefix);
             dBar.SetDistribBarWidth(width);
         }
         else
         {
             bar.sizeDelta = new Vector2(width, bar.rect.height);
         }
     }
     else
     {
         Debug.LogWarning(barName + " doesn't exist. Eligible barNames are OriginalGraphDot, CurrentGraphBar, TargetGraphDot, OrigTargetSameGraphDot");
     }
 }