void OnGUI() { GUIHelper.DrawArea(GUIHelper.ClientArea, true, () => { scrollPos = GUILayout.BeginScrollView(scrollPos); // Draw out the textures GUILayout.SelectionGrid(0, Textures, 3); #if !BESTHTTP_DISABLE_CACHING if (finishedCount == Images.Length && allDownloadedFromLocalCache) { GUIHelper.DrawCenteredText("All images loaded from the local cache!"); } #endif GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Label("Max Connection/Server: ", GUILayout.Width(150)); GUILayout.Label(HTTPManager.MaxConnectionPerServer.ToString(), GUILayout.Width(20)); HTTPManager.MaxConnectionPerServer = (byte)GUILayout.HorizontalSlider(HTTPManager.MaxConnectionPerServer, 1, 10); GUILayout.EndHorizontal(); if (GUILayout.Button("Start Download")) { DownloadImages(); } GUILayout.EndScrollView(); }); }
private void OnGUI() { GUIHelper.DrawArea(GUIHelper.ClientArea, true, (Action)(() => { this.scrollPos = GUILayout.BeginScrollView(this.scrollPos); GUILayout.SelectionGrid(0, (Texture[])this.Textures, 3); if (this.finishedCount == this.Images.Length && this.allDownloadedFromLocalCache) { GUIHelper.DrawCenteredText("All images loaded from the local cache!"); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.Label("Max Connection/Server: ", new GUILayoutOption[1] { GUILayout.Width(150f) }); GUILayout.Label(HTTPManager.MaxConnectionPerServer.ToString(), new GUILayoutOption[1] { GUILayout.Width(20f) }); HTTPManager.MaxConnectionPerServer = (byte)GUILayout.HorizontalSlider((float)HTTPManager.MaxConnectionPerServer, 1f, 10f); GUILayout.EndHorizontal(); if (GUILayout.Button("Start Download")) { this.DownloadImages(); } GUILayout.EndScrollView(); })); }
public static void DrawArea(Rect area, bool drawHeader, System.Action action) { GUIHelper.Setup(); GUI.Box(area, string.Empty); GUILayout.BeginArea(area); if (drawHeader) { GUIHelper.DrawCenteredText(SampleSelector.SelectedSample.DisplayName); GUILayout.Space(5f); } if (action != null) { action(); } GUILayout.EndArea(); }
/// <summary> /// Called from an OnGUI event to draw the Login Screen. /// </summary> void DrawLoginScreen() { GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUIHelper.DrawCenteredText("What's your nickname?"); Nick = GUILayout.TextField(Nick); if (GUILayout.Button("Join")) { Join(); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); }
/// <summary> /// Called from an OnGUI event to draw the Login Screen. /// </summary> void DrawLoginScreen() { GUIHelper.DrawArea(GUIHelper.ClientArea, true, () => { GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUIHelper.DrawCenteredText("What's your nickname?"); userName = GUILayout.TextField(userName); if (GUILayout.Button("Join")) { SetUserName(); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); }); }
private void DrawSample(SampleDescriptor sample) { if (sample.IsLabel) { GUILayout.Space(15); GUIHelper.DrawCenteredText(sample.DisplayName); GUILayout.Space(5); } else if (GUILayout.Button(sample.DisplayName)) { sample.IsSelected = true; if (SelectedSample != null) { SelectedSample.IsSelected = false; } SelectedSample = sample; } }
private void DrawSampleDetails(SampleDescriptor sample) { Rect area = new Rect(Screen.width / 3, statisticsHeight + 5, (Screen.width / 3) * 2, Screen.height - statisticsHeight - 5); GUI.Box(area, string.Empty); GUILayout.BeginArea(area); GUILayout.BeginVertical(); GUIHelper.DrawCenteredText(sample.DisplayName); GUILayout.Space(5); GUILayout.Label(sample.Description); GUILayout.FlexibleSpace(); if (GUILayout.Button("Start Sample")) { sample.CreateUnityObject(); } GUILayout.EndVertical(); GUILayout.EndArea(); }
void OnGUI() { switch (State) { case States.Connecting: GUIHelper.DrawArea(GUIHelper.ClientArea, true, () => { GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUIHelper.DrawCenteredText("Connecting to the server..."); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); }); break; case States.WaitForNick: GUIHelper.DrawArea(GUIHelper.ClientArea, true, () => { DrawLoginScreen(); }); break; case States.Joined: GUIHelper.DrawArea(GUIHelper.ClientArea, true, () => { // Draw Texture if (FrameTexture != null) { GUILayout.Box(FrameTexture); } DrawControls(); DrawChat(); }); break; } }
private void OnGUI() { GUIHelper.DrawArea(GUIHelper.ClientArea, true, delegate { this.scrollPos = GUILayout.BeginScrollView(this.scrollPos, Array.Empty <GUILayoutOption>()); GUILayout.SelectionGrid(0, this.Textures, 3, Array.Empty <GUILayoutOption>()); if ((this.finishedCount == this.Images.Length) && this.allDownloadedFromLocalCache) { GUIHelper.DrawCenteredText("All images loaded from the local cache!"); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(Array.Empty <GUILayoutOption>()); GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.Width(150f) }; GUILayout.Label("Max Connection/Server: ", optionArray1); GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(20f) }; GUILayout.Label(HTTPManager.MaxConnectionPerServer.ToString(), optionArray2); HTTPManager.MaxConnectionPerServer = (byte)GUILayout.HorizontalSlider((float)HTTPManager.MaxConnectionPerServer, 1f, 10f, Array.Empty <GUILayoutOption>()); GUILayout.EndHorizontal(); if (GUILayout.Button("Start Download", Array.Empty <GUILayoutOption>())) { this.DownloadImages(); } GUILayout.EndScrollView(); }); }
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(); } }