Skip to content

Commit

Permalink
Fix for unity 2020
Browse files Browse the repository at this point in the history
Fixing an issue with project path being not initialised on the first call to initialise. Seems unity 2020 has changed  default order of execution RuntimeInitializeOnLoadMethod and Awakes
  • Loading branch information
JakubSlaby committed Apr 17, 2021
1 parent a8e6a8f commit 0cbb49c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion WhiteSparrow/Logging/Chirp/Chirp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum LogLevel

public static class Chirp
{
public const string Version = "0.8.0";
public const string Version = "0.8.1";

private static ILogger[] s_Loggers;

Expand Down
6 changes: 3 additions & 3 deletions WhiteSparrow/Logging/Chirp/Utils/LoggingStackTraceUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ private static StringBuilder s_StackTraceBuilder
}

[RuntimeInitializeOnLoadMethod]
private static void InitializeOnLoad()
private static void InitializeProjectPath()
{
s_ProjectPath = Application.dataPath;
var i = s_ProjectPath.LastIndexOf("Assets");
var i = s_ProjectPath.LastIndexOf("Assets", StringComparison.Ordinal);
if (i != -1)
s_ProjectPath = s_ProjectPath.Substring(0, i);
s_ProjectPath = s_ProjectPath.Replace('/', Path.DirectorySeparatorChar);
Expand Down Expand Up @@ -83,7 +83,7 @@ public static string FormatUnityStackTrace(StackTrace stackTrace)
!(declaringType.Namespace == "UnityEngine")))
{
stringBuilder.Append(" (at ");
if (str2.StartsWith(s_ProjectPath))
if (s_ProjectPath != null && str2.StartsWith(s_ProjectPath))
str2 = str2.Substring(s_ProjectPath.Length);
stringBuilder.Append(str2);
stringBuilder.Append(":");
Expand Down

0 comments on commit 0cbb49c

Please sign in to comment.