mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交帧同步案例
This commit is contained in:
101
JNFrame/Assets/Plugins/BestHTTP/Examples/Helpers/GUIHelper.cs
Normal file
101
JNFrame/Assets/Plugins/BestHTTP/Examples/Helpers/GUIHelper.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BestHTTP.Examples
|
||||
{
|
||||
public static class GUIHelper
|
||||
{
|
||||
public static string BaseURL = "https://besthttpdemosite.azurewebsites.net";
|
||||
|
||||
private static GUIStyle centerAlignedLabel;
|
||||
private static GUIStyle rightAlignedLabel;
|
||||
|
||||
public static Rect ClientArea;
|
||||
|
||||
private static void Setup()
|
||||
{
|
||||
// These has to be called from OnGUI
|
||||
if (centerAlignedLabel == null)
|
||||
{
|
||||
centerAlignedLabel = new GUIStyle(GUI.skin.label);
|
||||
centerAlignedLabel.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
rightAlignedLabel = new GUIStyle(GUI.skin.label);
|
||||
rightAlignedLabel.alignment = TextAnchor.MiddleRight;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawArea(Rect area, bool drawHeader, Action action)
|
||||
{
|
||||
Setup();
|
||||
|
||||
// Draw background
|
||||
GUI.Box(area, string.Empty);
|
||||
GUILayout.BeginArea(area);
|
||||
|
||||
if (drawHeader)
|
||||
{
|
||||
GUIHelper.DrawCenteredText(SampleSelector.SelectedSample.DisplayName);
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
|
||||
if (action != null)
|
||||
action();
|
||||
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
|
||||
public static void DrawCenteredText(string msg)
|
||||
{
|
||||
Setup();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(msg, centerAlignedLabel);
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
public static void DrawRow(string key, string value)
|
||||
{
|
||||
Setup();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label(key);
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(value, rightAlignedLabel);
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
public class GUIMessageList
|
||||
{
|
||||
System.Collections.Generic.List<string> messages = new System.Collections.Generic.List<string>();
|
||||
Vector2 scrollPos;
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
Draw(Screen.width, 0);
|
||||
}
|
||||
|
||||
public void Draw(float minWidth, float minHeight)
|
||||
{
|
||||
scrollPos = GUILayout.BeginScrollView(scrollPos, false, false, GUILayout.MinHeight(minHeight));
|
||||
for (int i = 0; i < messages.Count; ++i)
|
||||
GUILayout.Label(messages[i], GUILayout.MinWidth(minWidth));
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
public void Add(string msg)
|
||||
{
|
||||
messages.Add(msg);
|
||||
scrollPos = new Vector2(scrollPos.x, float.MaxValue);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
messages.Clear();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd560ff6f0fa60844a43a82db1ad03be
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user