コード例 #1
0
 /// <summary>
 /// 获取下载速度
 /// </summary>
 /// <param name="time">计算间隔时间</param>
 /// <returns></returns>
 public string GetDownloaderSpeed(float time = 0.5f)
 {
     countTime += Time.deltaTime;
     if (countTime >= time)
     {
         long curTotalSaveLength = 0;
         foreach (var item in downloaderHandlers)
         {
             curTotalSaveLength += item.Value.GetCurLength();
         }
         downloadSpeed       = ByteUtil.AutoUnitConversion((curTotalSaveLength - lastTotalSaveLength) / time) + "/S";
         lastTotalSaveLength = curTotalSaveLength;
         countTime           = 0;
     }
     return(downloadSpeed);
 }
コード例 #2
0
            public void OnDraw()
            {
                string typeName = typeof(T).Name;

                //GUILayout.Label("<b>" + typeName + " Runtime Memory Information</b>");
                GUILayout.BeginVertical("box");
                {
                    m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);
                    {
                        if (GUILayout.Button("Take Sample for " + typeName, GUILayout.Height(30f)))
                        {
                            TakeSample();
                        }
                        if (sampleTime <= DateTime.MinValue)
                        {
                            GUILayout.Label("<b>Please take sample for " + typeName + " first</b>");
                        }
                        else
                        {
                            if (duplicateSampleCount > 0)
                            {
                                GUILayout.Label("<b>" + samples.Count.ToString() + " " + typeName + "s(" + ByteUtil.AutoUnitConversion(sampleSize) + ") obtained at " + sampleTime.ToString("yyyy-MM-dd HH:mm:ss") + ", while " + duplicateSampleCount.ToString() + " " + typeName + "s (" + ByteUtil.AutoUnitConversion(duplicateSampleSize) + ") might be duplicated.</b>");
                            }
                            else

                            {
                                GUILayout.Label("<b>" + samples.Count.ToString() + " " + typeName + "s(" + ByteUtil.AutoUnitConversion(sampleSize) + ") obtained at " + sampleTime.ToString("yyyy-MM-dd HH:mm:ss") + "</b>");
                            }
                            if (samples.Count > 0)
                            {
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label("<b>Name</b>");
                                    GUILayout.Label("<b>Type</b>", GUILayout.Width(240f));
                                    GUILayout.Label("<b>Size</b>", GUILayout.Width(80f));
                                }
                                GUILayout.EndHorizontal();
                            }
                            int count = 0;
                            for (int i = 0; i < samples.Count; i++)
                            {
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label(samples[i].HighLight ? "<color=yellow>" + samples[i].Name + "</color>" : samples[i].Name);
                                    GUILayout.Label(samples[i].HighLight ? "<color=yellow>" + samples[i].Type + "</color>" : samples[i].Type, GUILayout.Width(240f));
                                    GUILayout.Label(samples[i].HighLight ? "<color=yellow>" + ByteUtil.AutoUnitConversion(samples[i].Size) + "</color>" : ByteUtil.AutoUnitConversion(samples[i].Size), GUILayout.Width(80f));
                                }
                                GUILayout.EndHorizontal();

                                count++;
                                if (count >= showSampleCount)
                                {
                                    break;
                                }
                            }
                        }
                        GUILayout.EndScrollView();
                    }
                }
                GUILayout.EndVertical();
            }