Skip to content

Commit ca98889

Browse files
authored
Update UnityFileDebug.cs
Fix crashing bug with "Warning" Unity Log =================================== ArgumentOutOfRangeException: Cannot be negative. Parameter name: length System.String.Substring (Int32 startIndex, Int32 length) ===================================
1 parent 3082408 commit ca98889

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

Assets/UnityFileDebug/Lib/Logger/Scripts/UnityFileDebug.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using UnityEngine;
2-
1+
using UnityEngine;
2+
33
namespace SSS
44
{
55
namespace UnityFileDebug
@@ -12,16 +12,16 @@ public class LogOutput
1212
public string tm; //time
1313
public string l; //log
1414
public string s; //stack
15-
}
16-
15+
}
16+
1717
public enum FileType
1818
{
1919
CSV,
2020
JSON,
2121
TSV,
2222
TXT
23-
}
24-
23+
}
24+
2525
[ExecuteInEditMode]
2626
public class UnityFileDebug : MonoBehaviour
2727
{
@@ -115,8 +115,16 @@ void HandleLog(string logString, string stackTrace, LogType type)
115115
else
116116
{
117117
int end = logString.IndexOf("]");
118-
output.t = logString.Substring(1, end - 1);
119-
output.l = logString.Substring(end + 2);
118+
if (end > 1)
119+
{
120+
output.t = logString.Substring(1, end - 1);
121+
output.l = logString.Substring(end + 2);
122+
}
123+
else
124+
{
125+
output.t = type.ToString();
126+
output.l = logString;
127+
}
120128
}
121129

122130
output.s = stackTrace;
@@ -145,4 +153,4 @@ void HandleLog(string logString, string stackTrace, LogType type)
145153
}
146154
}
147155
}
148-
}
156+
}

0 commit comments

Comments
 (0)