Last active
May 16, 2022 18:52
-
-
Save SolidAlloy/68b02da3c774c6691da7dab2eba190cc to your computer and use it in GitHub Desktop.
Workaround for when Unity complains about the missing RoslynAnalysisRunner folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System.Text.RegularExpressions; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
internal static class RoslynDirectoryCreator | |
{ | |
static RoslynDirectoryCreator() => Application.logMessageReceived += OnLogMessageReceived; | |
private static void OnLogMessageReceived(string message, string _, LogType logType) | |
{ | |
if (logType != LogType.Exception) | |
return; | |
const string pattern = | |
@"^DirectoryNotFoundException: Could not find " + | |
@"a part of the path ('|"")Temp(\\|/)RoslynAnalysisRunner"; | |
if (Regex.IsMatch(message, pattern)) | |
{ | |
Directory.CreateDirectory("Temp/RoslynAnalysisRunner"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot, it works