예제 #1
0
        //'Each' mode
        private void UpdateForEashTye(CpuRateInfo info)
        {
            float total = info.user;

            UserBarFill = total / 100f;

            total      += info.nice;
            NiceBarFill = total / 100f;

            total        += info.system;
            SystemBarFill = total / 100f;

            IdleBarFill = 1f;
        }
예제 #2
0
        //'UseGrad' mode
        private void UpdateForUseGradTye(CpuRateInfo info)
        {
            NiceBarFill   = 0f;
            SystemBarFill = 0f;
            IdleBarFill   = 1f;

            float rate = (info.user + info.nice + info.system) / 100f;

            UserBarFill = rate;

            if (useGradColor != null)
            {
                UserBarColor = useGradColor.Evaluate(rate);
            }
        }
예제 #3
0
        // Update is called once per frame
        //private void Update () {

        //}


        //'CpuRateInfo' to bar
        public void SetCpuRate(CpuRateInfo info)
        {
            if (nameText != null)
            {
                nameText.text = info.name.ToUpper() + " : ";
            }

            switch (barType)
            {
            case BarType.Each:
                UpdateForEashTye(info);
                break;

            case BarType.UseGrad:
                UpdateForUseGradTye(info);
                break;
            }
        }
예제 #4
0
        //Callback handler for CPU Rate information.
        private void ReceiveStatus(string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                return;
            }

            string[]      items = json.Split('\n');
            CpuRateInfo[] infos = new CpuRateInfo[items.Length];

            for (int i = 0; i < infos.Length; i++)
            {
                infos[i] = JsonUtility.FromJson <CpuRateInfo>(items[i]);
            }

            if (OnStatus != null)
            {
                OnStatus.Invoke(infos);
            }
        }