Skip to content

Commit a7ff7ea

Browse files
author
Jiang Yin
committed
修改Debugger
1 parent cfcaa47 commit a7ff7ea

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

Scripts/Editor/ResourceBuilder/ResourceBuilder.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//------------------------------------------------------------
77

88
using GameFramework;
9+
using System;
910
using System.IO;
1011
using UnityEditor;
1112
using UnityEngine;
@@ -346,7 +347,7 @@ private void GetBuildMessage(out string message, out MessageType messageType)
346347
{
347348
if (!string.IsNullOrEmpty(message))
348349
{
349-
message += "\n";
350+
message += Environment.NewLine;
350351
}
351352

352353
message += "Platform is invalid.";
@@ -356,7 +357,7 @@ private void GetBuildMessage(out string message, out MessageType messageType)
356357
{
357358
if (!string.IsNullOrEmpty(message))
358359
{
359-
message += "\n";
360+
message += Environment.NewLine;
360361
}
361362

362363
message += "Compression helper is invalid.";
@@ -366,7 +367,7 @@ private void GetBuildMessage(out string message, out MessageType messageType)
366367
{
367368
if (!string.IsNullOrEmpty(message))
368369
{
369-
message += "\n";
370+
message += Environment.NewLine;
370371
}
371372

372373
message += "Output directory is invalid.";

Scripts/Editor/ResourcePackBuilder/ResourcePackBuilder.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//------------------------------------------------------------
77

88
using GameFramework;
9+
using System;
910
using UnityEditor;
1011
using UnityEngine;
1112

@@ -172,7 +173,7 @@ private void OnGUI()
172173
{
173174
if (!string.IsNullOrEmpty(message))
174175
{
175-
message += "\n";
176+
message += Environment.NewLine;
176177
}
177178

178179
message += "Working directory is invalid.";
@@ -182,7 +183,7 @@ private void OnGUI()
182183
{
183184
if (!string.IsNullOrEmpty(message))
184185
{
185-
message += "\n";
186+
message += Environment.NewLine;
186187
}
187188

188189
message += "Platform is invalid.";
@@ -192,7 +193,7 @@ private void OnGUI()
192193
{
193194
if (!string.IsNullOrEmpty(message))
194195
{
195-
message += "\n";
196+
message += Environment.NewLine;
196197
}
197198

198199
message += "Compression helper is invalid.";

Scripts/Runtime/Debugger/DebuggerComponent.ConsoleWindow.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public sealed partial class DebuggerComponent : GameFrameworkComponent
1919
private sealed class ConsoleWindow : IDebuggerWindow
2020
{
2121
private readonly Queue<LogNode> m_LogNodes = new Queue<LogNode>();
22-
private readonly TextEditor m_TextEditor = new TextEditor();
2322

2423
private SettingComponent m_SettingComponent = null;
2524
private Vector2 m_LogScrollPosition = Vector2.zero;
@@ -367,21 +366,14 @@ public void OnDraw()
367366
{
368367
if (m_SelectedNode != null)
369368
{
370-
GUILayout.BeginHorizontal();
371369
Color32 color = GetLogStringColor(m_SelectedNode.LogType);
372-
GUILayout.Label(Utility.Text.Format("<color=#{0}{1}{2}{3}><b>{4}</b></color>", color.r.ToString("x2"), color.g.ToString("x2"), color.b.ToString("x2"), color.a.ToString("x2"), m_SelectedNode.LogMessage));
373-
if (GUILayout.Button("COPY", GUILayout.Width(60f), GUILayout.Height(30f)))
370+
if (GUILayout.Button(Utility.Text.Format("<color=#{0}{1}{2}{3}><b>{4}</b></color>{6}{6}{5}", color.r.ToString("x2"), color.g.ToString("x2"), color.b.ToString("x2"), color.a.ToString("x2"), m_SelectedNode.LogMessage, m_SelectedNode.StackTrack, Environment.NewLine), "label"))
374371
{
375-
m_TextEditor.text = Utility.Text.Format("{0}{2}{2}{1}", m_SelectedNode.LogMessage, m_SelectedNode.StackTrack, Environment.NewLine);
376-
m_TextEditor.OnFocus();
377-
m_TextEditor.Copy();
378-
m_TextEditor.text = null;
372+
CopyToClipboard(Utility.Text.Format("{0}{2}{2}{1}", m_SelectedNode.LogMessage, m_SelectedNode.StackTrack, Environment.NewLine));
379373
}
380-
GUILayout.EndHorizontal();
381-
GUILayout.Label(m_SelectedNode.StackTrack);
382374
}
383-
GUILayout.EndScrollView();
384375
}
376+
GUILayout.EndScrollView();
385377
}
386378
GUILayout.EndVertical();
387379
}

Scripts/Runtime/Debugger/DebuggerComponent.ScrollableDebuggerWindowBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ protected static void DrawItem(string title, string content)
5454
GUILayout.BeginHorizontal();
5555
{
5656
GUILayout.Label(title, GUILayout.Width(TitleWidth));
57-
GUILayout.Label(content);
57+
if (GUILayout.Button(content, "label"))
58+
{
59+
CopyToClipboard(content);
60+
}
5861
}
5962
GUILayout.EndHorizontal();
6063
}

Scripts/Runtime/Debugger/DebuggerComponent.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public sealed partial class DebuggerComponent : GameFrameworkComponent
3434
/// </summary>
3535
internal static readonly float DefaultWindowScale = 1f;
3636

37+
private static readonly TextEditor s_TextEditor = new TextEditor();
3738
private IDebuggerManager m_DebuggerManager = null;
3839
private Rect m_DragRect = new Rect(0f, 0f, float.MaxValue, 25f);
3940
private Rect m_IconRect = DefaultIconRect;
@@ -424,5 +425,13 @@ private void DrawDebuggerWindowIcon(int windowId)
424425
m_ShowFullWindow = true;
425426
}
426427
}
428+
429+
private static void CopyToClipboard(string content)
430+
{
431+
s_TextEditor.text = content;
432+
s_TextEditor.OnFocus();
433+
s_TextEditor.Copy();
434+
s_TextEditor.text = null;
435+
}
427436
}
428437
}

0 commit comments

Comments
 (0)