コード例 #1
0
        public IEnumerator AnimateBarsWithAnimTypeThree(BarProperty bar, float barScale, float yValue, float animSpeed, bool isUpdating, Color barColor, Color barStartColor)
        {
            while (true)
            {
                BarProperty barProperty = bar.GetComponent <BarProperty>();
                Color       barCol      = Color.Lerp(barProperty.GetBarColor(), barColor, Time.deltaTime * animSpeed * 0.4f);
                barProperty.SetBarColor(barCol);
                Vector3 targetScale = new Vector3(bar.transform.localScale.x, barScale, bar.transform.localScale.z);
                if (bar.transform.localScale.y > targetScale.y)
                {
                    Vector3 scale = bar.transform.localScale - new Vector3(0, Time.deltaTime * animSpeed, 0);
                    scale.y = Mathf.Clamp(scale.y, targetScale.y, yValue);
                    bar.transform.localScale = scale;



                    if (bar.transform.localScale.y <= targetScale.y)
                    {
                        barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
                        barProperty.SetBarColor(barColor);
                        break;
                    }
                }
                else
                {
                    Vector3 scale = bar.transform.localScale + new Vector3(0, Time.deltaTime * animSpeed, 0);
                    scale.y = Mathf.Clamp(scale.y, 0, targetScale.y);
                    bar.transform.localScale = scale;


                    if (bar.transform.localScale.y >= targetScale.y)
                    {
                        barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
                        barProperty.SetBarColor(barColor);
                        break;
                    }
                }



                yield return(new WaitForEndOfFrame());
            }

            if (isUpdating)
            {
                GraphUpdated();
            }

            yield return(new WaitForEndOfFrame());
        }
コード例 #2
0
        public IEnumerator AnimateBarsWithAnimTypeOne(BarProperty bar, float barScale, float yValue, float animSpeed, bool isUpdating)
        {
            while (true)
            {
                Vector3     targetScale = new Vector3(bar.transform.localScale.x, barScale, bar.transform.localScale.z);
                BarProperty barProperty = bar.GetComponent <BarProperty>();

                if (bar.transform.localScale.y > targetScale.y)
                {
                    Vector3 scale = bar.transform.localScale - new Vector3(0, Time.deltaTime * animSpeed, 0);
                    scale.y = Mathf.Clamp(scale.y, targetScale.y, yValue);
                    Debug.Log($"y scale {scale.y} traget scale {targetScale.y} yvalue {yValue}");
                    bar.transform.localScale = scale;

                    if (bar.transform.localScale.y <= targetScale.y)
                    {
                        barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
                        break;
                    }
                }
                else
                {
                    Vector3 scale = bar.transform.localScale + new Vector3(0, Time.deltaTime * animSpeed, 0);
                    scale.y = Mathf.Clamp(scale.y, 0, targetScale.y);

                    Debug.Log($"y scale {scale.y} traget scale {targetScale.y} yvalue {yValue}");
                    bar.transform.localScale = scale;
                    if (bar.transform.localScale.y >= targetScale.y)
                    {
                        barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
                        break;
                    }
                }

                yield return(new WaitForEndOfFrame());
            }

            if (isUpdating)
            {
                GraphUpdated();
            }

            yield return(new WaitForEndOfFrame());
        }