-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCompileErrorListener.cs
More file actions
60 lines (53 loc) · 1.72 KB
/
Copy pathCompileErrorListener.cs
File metadata and controls
60 lines (53 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
namespace Shell.Protector
{
[InitializeOnLoad]
public class CompileErrorListener
{
private static int retryLimit = 3;
private static int retryCount = 0;
static CompileErrorListener()
{
CompilationPipeline.assemblyCompilationFinished += OnAssemblyCompilationFinished;
}
private static void OnAssemblyCompilationFinished(string assembly, CompilerMessage[] messages)
{
bool foundTargetError = false;
foreach (var m in messages)
{
if (m.type != CompilerMessageType.Error)
continue;
if (
m.message.Contains("The type or namespace name 'lilToonInspector' could not be found") ||
m.message.Contains("The type or namespace name 'Thry' could not be found") ||
m.message.Contains("The name 'ShaderOptimizer' does not exist in the current context")
)
{
foundTargetError = true;
break;
}
}
if (foundTargetError)
{
retryCount++;
if (retryCount <= retryLimit)
{
Debug.LogErrorFormat("Shader check error -> ResetDefine {0}/{0}", retryCount, retryLimit);
AssetManager.GetInstance().ResetDefine();
}
else
{
Debug.LogError("Failed ResetDefine");
}
}
else
{
retryCount = 0;
}
}
}
}
#endif