From 31e65b5a7d55c3d08a8d8348bc9dba9a123cea95 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Tue, 21 Nov 2023 14:23:04 +0200 Subject: [PATCH] Add the CompileListener from game-ci to create github annotations of errors and warnings --- Assets/Editor/BuildCompileListener.cs | 36 ++++++++++++++++++++++ Assets/Editor/BuildCompileListener.cs.meta | 11 +++++++ 2 files changed, 47 insertions(+) create mode 100644 Assets/Editor/BuildCompileListener.cs create mode 100644 Assets/Editor/BuildCompileListener.cs.meta diff --git a/Assets/Editor/BuildCompileListener.cs b/Assets/Editor/BuildCompileListener.cs new file mode 100644 index 0000000000..4dc14570df --- /dev/null +++ b/Assets/Editor/BuildCompileListener.cs @@ -0,0 +1,36 @@ +using System; +using UnityEngine; +using UnityEditor; + +namespace UnityBuilderAction.Reporting +{ + [InitializeOnLoad] + static class CompileListener + { + static CompileListener() + { + if (Application.isBatchMode) + { + Application.logMessageReceived += Application_logMessageReceived; + } + } + + private static void Application_logMessageReceived(string condition, string stackTrace, LogType type) + { + string prefix = ""; + switch (type) + { + case LogType.Error: + prefix = "error"; + break; + case LogType.Warning: + prefix = "warning"; + break; + case LogType.Exception: + prefix = "error"; + break; + } + Console.WriteLine($"{Environment.NewLine}::{prefix} ::{condition}{Environment.NewLine}{stackTrace}"); + } + } +} diff --git a/Assets/Editor/BuildCompileListener.cs.meta b/Assets/Editor/BuildCompileListener.cs.meta new file mode 100644 index 0000000000..85f848df2e --- /dev/null +++ b/Assets/Editor/BuildCompileListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 345651e0f7d8b4ccf930d5e1935b9691 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: