Esempio n. 1
0
        protected virtual void Update()
        {
            var finalCounters = counters.Count > 0 ? counters : null;
            var total         = P3dChannelCounter.GetTotal(finalCounters);
            var count         = default(long);

            switch (channel)
            {
            case ChannelType.Red:   count = P3dChannelCounter.GetCountR(finalCounters); break;

            case ChannelType.Green: count = P3dChannelCounter.GetCountG(finalCounters); break;

            case ChannelType.Blue:  count = P3dChannelCounter.GetCountB(finalCounters); break;

            case ChannelType.Alpha: count = P3dChannelCounter.GetCountA(finalCounters); break;
            }

            if (inverse == true)
            {
                count = total - count;
            }

            var final   = format;
            var percent = P3dHelper.RatioToPercentage(P3dHelper.Divide(count, total), decimalPlaces);

            final = final.Replace("{TOTAL}", total.ToString());
            final = final.Replace("{COUNT}", count.ToString());
            final = final.Replace("{PERCENT}", percent.ToString());

            cachedText.text = final;
        }
Esempio n. 2
0
        protected virtual void Update()
        {
            var finalCounters = counters.Count > 0 ? counters : null;
            var ratio         = 0.0f;

            switch (channel)
            {
            case ChannelType.Red:   ratio = P3dChannelCounter.GetRatioR(finalCounters); break;

            case ChannelType.Green: ratio = P3dChannelCounter.GetRatioG(finalCounters); break;

            case ChannelType.Blue:  ratio = P3dChannelCounter.GetRatioB(finalCounters); break;

            case ChannelType.Alpha: ratio = P3dChannelCounter.GetRatioA(finalCounters); break;
            }

            if (inverse == true)
            {
                ratio = 1.0f - ratio;
            }

            cachedImage.fillAmount = Mathf.Clamp01(ratio);
        }