Exemple #1
0
 private TextListItem AddText(string text)
 {
     return GUIHelper.AddText(this._listItemPrefab, this._contentRoot, text, this._maxListItemEntries, this._scrollRect);
 }
        void OnGUI()
        {
            var stats = HTTPManager.GetGeneralStatistics(StatisticsQueryFlags.All);

            // Connection statistics
            GUIHelper.DrawArea(new Rect(0, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                // Header
                GUIHelper.DrawCenteredText("Connections");

                GUILayout.Space(5);

                GUIHelper.DrawRow("Sum:", stats.Connections.ToString());
                GUIHelper.DrawRow("Active:", stats.ActiveConnections.ToString());
                GUIHelper.DrawRow("Free:", stats.FreeConnections.ToString());
                GUIHelper.DrawRow("Recycled:", stats.RecycledConnections.ToString());
                GUIHelper.DrawRow("Requests in queue:", stats.RequestsInQueue.ToString());
            });

            // Cache statistics
            GUIHelper.DrawArea(new Rect(Screen.width / 3, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                GUIHelper.DrawCenteredText("Cache");

#if !BESTHTTP_DISABLE_CACHING
                if (!BestHTTP.Caching.HTTPCacheService.IsSupported)
                {
#endif
                GUI.color = Color.yellow;
                GUIHelper.DrawCenteredText("Disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
                GUI.color = Color.white;
#if !BESTHTTP_DISABLE_CACHING
            }
                               else
            {
                GUILayout.Space(5);

                GUIHelper.DrawRow("Cached entities:", stats.CacheEntityCount.ToString());
                GUIHelper.DrawRow("Sum Size (bytes): ", stats.CacheSize.ToString("N0"));

                GUILayout.BeginVertical();

                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Clear Cache"))
                {
                    BestHTTP.Caching.HTTPCacheService.BeginClear();
                }

                GUILayout.EndVertical();
            }
#endif
            });

            // Cookie statistics
            GUIHelper.DrawArea(new Rect((Screen.width / 3) * 2, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                GUIHelper.DrawCenteredText("Cookies");

#if !BESTHTTP_DISABLE_COOKIES
                if (!BestHTTP.Cookies.CookieJar.IsSavingSupported)
                {
#endif
                GUI.color = Color.yellow;
                GUIHelper.DrawCenteredText("Saving and loading from disk is disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
                GUI.color = Color.white;
#if !BESTHTTP_DISABLE_COOKIES
            }
                               else
            {
                GUILayout.Space(5);

                GUIHelper.DrawRow("Cookies:", stats.CookieCount.ToString());
                GUIHelper.DrawRow("Estimated size (bytes):", stats.CookieJarSize.ToString("N0"));

                GUILayout.BeginVertical();

                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Clear Cookies"))
                {
                    BestHTTP.Cookies.CookieJar.Clear();
                }

                GUILayout.EndVertical();
            }
#endif
            });

            if (SelectedSample == null || (SelectedSample != null && !SelectedSample.IsRunning))
            {
                // Draw the list of samples
                GUIHelper.DrawArea(new Rect(0, statisticsHeight + 5, SelectedSample == null ? Screen.width : Screen.width / 3, Screen.height - statisticsHeight - 5), false, () =>
                {
                    scrollPos = GUILayout.BeginScrollView(scrollPos);
                    for (int i = 0; i < Samples.Count; ++i)
                    {
                        DrawSample(Samples[i]);
                    }
                    GUILayout.EndScrollView();
                });

                if (SelectedSample != null)
                {
                    DrawSampleDetails(SelectedSample);
                }
            }
            else if (SelectedSample != null && SelectedSample.IsRunning)
            {
                GUILayout.BeginArea(new Rect(0, Screen.height - 50, Screen.width, 50), string.Empty);
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                GUILayout.BeginVertical();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Back", GUILayout.MinWidth(100)))
                {
                    SelectedSample.DestroyUnityObject();
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
                GUILayout.EndArea();
            }
        }