diff --git a/Assets/TEngine/Scripts/Runtime/Core/NetWork/Helper/ProtoUtils.cs b/Assets/TEngine/Scripts/Runtime/Core/NetWork/Helper/ProtoUtils.cs index 0ae990a1..29851d2e 100644 --- a/Assets/TEngine/Scripts/Runtime/Core/NetWork/Helper/ProtoUtils.cs +++ b/Assets/TEngine/Scripts/Runtime/Core/NetWork/Helper/ProtoUtils.cs @@ -1,4 +1,5 @@ -using System.IO; +using System.Diagnostics; +using System.IO; using System.Text; namespace TEngine.Runtime @@ -49,13 +50,16 @@ namespace TEngine.Runtime private static StringBuilder _stringBuilder = new StringBuilder(); - public static string GetBuffer(byte[] buffer) + public static string GetBuffer(byte[] buffer,int count = -1) { _stringBuilder.Length = 0; _stringBuilder.Append("["); - for (int i = 0; i < buffer.Length; i++) + + var length = count <= 0 ? buffer.Length : count; + + for (int i = 0; i < length; i++) { - if (i == buffer.Length - 1) + if (i == length - 1) { _stringBuilder.Append(buffer[i]); _stringBuilder.Append("]"); @@ -70,9 +74,10 @@ namespace TEngine.Runtime return _stringBuilder.ToString(); } - public static void PrintBuffer(byte[] buffer) + [Conditional("UNITY_EDITOR")][Conditional("ENABLE_LOG_BUFFER")] + public static void PrintBuffer(byte[] buffer,int count = -1) { - Log.Debug(GetBuffer(buffer)); + Log.Debug(GetBuffer(buffer,count)); } } } \ No newline at end of file