Exemple #1
0
 /// <summary>
 /// Coroutine to update the stats information
 /// </summary>
 /// <returns></returns>
 private IEnumerator UpdateTextStatus()
 {
     while (true)
     {
         if (NetworkManager.Singleton)
         {
             if (m_ClientMode)
             {
                 m_LastStatsDump  = m_IsServer ? "Server Stats" : "Client Stats";
                 m_LastStatsDump += "\ndeltaTime: [" + Time.deltaTime.ToString() + "]";
                 foreach (ProfilerStat p in ProfilerStatManager.AllStats)
                 {
                     if (m_LastStatsDump != string.Empty)
                     {
                         m_LastStatsDump += "\n";
                     }
                     m_LastStatsDump += p.PrettyPrintName + ": " + p.SampleRate().ToString("0.0");
                 }
             }
             if (NetworkManager.Singleton.IsServer && m_ClientsToUpdate.Count > 0)
             {
                 var statsInfoContainer = new StatsInfoContainer();
                 statsInfoContainer.StatValues = new List <float>();
                 foreach (ProfilerStat p in ProfilerStatManager.AllStats)
                 {
                     statsInfoContainer.StatValues.Add(p.SampleRate());
                 }
                 ReceiveStatsClientRPC(statsInfoContainer);
             }
         }
         yield return(new WaitForSeconds(0.5f));
     }
 }
Exemple #2
0
 private void ReceiveStatsClientRPC(StatsInfoContainer statsinfo)
 {
     m_LastStatsDump  = "Server Stats";
     m_LastStatsDump += "\ndeltaTime: [" + Time.deltaTime.ToString() + "]";
     if (ProfilerStatManager.AllStats.Count != statsinfo.StatValues.Count)
     {
         Debug.LogError("[StatsDisplay-Error][Mismatch] Recieved " + statsinfo.StatValues.Count.ToString() + " values and have " + ProfilerStatManager.AllStats.Count.ToString() + " profiler stats entries!");
     }
     else
     {
         var statsCounter = 0;
         foreach (ProfilerStat p in ProfilerStatManager.AllStats)
         {
             if (m_LastStatsDump != string.Empty)
             {
                 m_LastStatsDump += "\n";
             }
             m_LastStatsDump += p.PrettyPrintName + ": " + statsinfo.StatValues[statsCounter].ToString(("0.0"));
             statsCounter++;
         }
     }
 }