77 lines
2.5 KiB
C#
77 lines
2.5 KiB
C#
using UnityEngine;
|
|
|
|
public class GuiTextDebug : MonoBehaviour
|
|
{
|
|
private static string windowText = "";
|
|
private static readonly string windowText2 = "";
|
|
|
|
private static bool debugIsOn;
|
|
private static bool packetDebugIsOn;
|
|
public GUIStyle debugBoxStyle;
|
|
private readonly float debugWidth = 5000.0f;
|
|
|
|
private float leftSide = 300.0f;
|
|
private int positionCheck = 2;
|
|
private Vector2 scrollViewVector = Vector2.zero;
|
|
private float windowPosition = -440.0f;
|
|
|
|
private void Start()
|
|
{
|
|
leftSide = 120;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
if (debugIsOn)
|
|
{
|
|
GUI.depth = 0;
|
|
GUI.BeginGroup(new Rect(windowPosition, 40.0f, 1200, 2000));
|
|
|
|
scrollViewVector = GUI.BeginScrollView(new Rect(0, 0.0f, debugWidth, 2000),
|
|
scrollViewVector,
|
|
new Rect(0.0f, 0.0f, 800.0f, 2000.0f));
|
|
GUI.Box(new Rect(200, 0.0f, debugWidth - 20.0f, 2000.0f), windowText, debugBoxStyle);
|
|
GUI.EndScrollView();
|
|
|
|
//GUI.TextArea(new Rect(200, 0.0f, 300.0f, 50.0f), _VoiceDebugStr);
|
|
|
|
GUI.EndGroup();
|
|
}
|
|
|
|
if (packetDebugIsOn)
|
|
{
|
|
GUI.depth = 0;
|
|
GUI.BeginGroup(new Rect(windowPosition, 40.0f, 1200, 2000));
|
|
|
|
//net message
|
|
scrollViewVector = GUI.BeginScrollView(new Rect(200, 0.0f, debugWidth, 2000),
|
|
scrollViewVector,
|
|
new Rect(0.0f, 0.0f, 400.0f, 2000.0f));
|
|
//var msgText = "<color=#110000>" + windowText2 + "</color>";
|
|
GUI.Box(new Rect(200, 0.0f, debugWidth - 20.0f, 2000.0f), windowText2, debugBoxStyle);
|
|
GUI.EndScrollView();
|
|
|
|
//GUI.TextArea(new Rect(200, 0.0f, 300.0f, 50.0f), _VoiceDebugStr);
|
|
|
|
GUI.EndGroup();
|
|
}
|
|
|
|
if (GUI.Button(new Rect(leftSide, 0.0f, 75.0f, 40.0f), "调试")) debugIsOn = !debugIsOn;
|
|
if (GUI.Button(new Rect(leftSide + 80f, 0.0f, 75.0f, 40.0f), "协议")) packetDebugIsOn = !packetDebugIsOn;
|
|
windowPosition = leftSide;
|
|
|
|
if (GUI.Button(new Rect(leftSide + 160f, 0.0f, 75.0f, 40.0f), "清除")) windowText = "";
|
|
}
|
|
|
|
public static void debug(string newString)
|
|
{
|
|
Debug.Log(newString);
|
|
if (!debugIsOn)
|
|
return;
|
|
|
|
windowText = newString + "\n" + windowText;
|
|
if (windowText.Length > 2000) windowText = windowText.Substring(0, 1000);
|
|
Debug.Log(newString);
|
|
}
|
|
} |