Beispiel #1
0
    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 && (!UNITY_WEBGL || UNITY_EDITOR)
            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 && (!UNITY_WEBGL || UNITY_EDITOR)
        }
                           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 && (!UNITY_WEBGL || UNITY_EDITOR)
            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 && (!UNITY_WEBGL || UNITY_EDITOR)
        }
                           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();
                BestHTTP.HTTPManager.OnQuit();
            }

            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();
        }
    }
Beispiel #2
0
    // Token: 0x060025A8 RID: 9640 RVA: 0x000B99E4 File Offset: 0x000B7DE4
    private void OnGUI()
    {
        GeneralStatistics stats = HTTPManager.GetGeneralStatistics(StatisticsQueryFlags.All);

        GUIHelper.DrawArea(new Rect(0f, 0f, (float)(Screen.width / 3), 160f), false, delegate
        {
            GUIHelper.DrawCenteredText("Connections");
            GUILayout.Space(5f);
            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());
        });
        GUIHelper.DrawArea(new Rect((float)(Screen.width / 3), 0f, (float)(Screen.width / 3), 160f), false, delegate
        {
            GUIHelper.DrawCenteredText("Cache");
            if (!HTTPCacheService.IsSupported)
            {
                GUI.color = Color.yellow;
                GUIHelper.DrawCenteredText("Disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
                GUI.color = Color.white;
            }
            else
            {
                GUILayout.Space(5f);
                GUIHelper.DrawRow("Cached entities:", stats.CacheEntityCount.ToString());
                GUIHelper.DrawRow("Sum Size (bytes): ", stats.CacheSize.ToString("N0"));
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Clear Cache", new GUILayoutOption[0]))
                {
                    HTTPCacheService.BeginClear();
                }
                GUILayout.EndVertical();
            }
        });
        GUIHelper.DrawArea(new Rect((float)(Screen.width / 3 * 2), 0f, (float)(Screen.width / 3), 160f), false, delegate
        {
            GUIHelper.DrawCenteredText("Cookies");
            if (!CookieJar.IsSavingSupported)
            {
                GUI.color = Color.yellow;
                GUIHelper.DrawCenteredText("Saving and loading from disk is disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
                GUI.color = Color.white;
            }
            else
            {
                GUILayout.Space(5f);
                GUIHelper.DrawRow("Cookies:", stats.CookieCount.ToString());
                GUIHelper.DrawRow("Estimated size (bytes):", stats.CookieJarSize.ToString("N0"));
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Clear Cookies", new GUILayoutOption[0]))
                {
                    HTTPManager.OnQuit();
                }
                GUILayout.EndVertical();
            }
        });
        if (SampleSelector.SelectedSample == null || (SampleSelector.SelectedSample != null && !SampleSelector.SelectedSample.IsRunning))
        {
            GUIHelper.DrawArea(new Rect(0f, 165f, (float)((SampleSelector.SelectedSample != null) ? (Screen.width / 3) : Screen.width), (float)(Screen.height - 160 - 5)), false, delegate
            {
                this.scrollPos = GUILayout.BeginScrollView(this.scrollPos, new GUILayoutOption[0]);
                for (int i = 0; i < this.Samples.Count; i++)
                {
                    this.DrawSample(this.Samples[i]);
                }
                GUILayout.EndScrollView();
            });
            if (SampleSelector.SelectedSample != null)
            {
                this.DrawSampleDetails(SampleSelector.SelectedSample);
            }
        }
        else if (SampleSelector.SelectedSample != null && SampleSelector.SelectedSample.IsRunning)
        {
            GUILayout.BeginArea(new Rect(0f, (float)(Screen.height - 50), (float)Screen.width, 50f), string.Empty);
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Back", new GUILayoutOption[]
            {
                GUILayout.MinWidth(100f)
            }))
            {
                SampleSelector.SelectedSample.DestroyUnityObject();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
    }