Share the Unity log callback with VSTU

Visual Studio Tools for Unity registers a log callback with Unity to be able to stream its console to Visual Studio. If your editor scripts also register a log callback with Unity, the VSTU callback might interfere with your callback. To prevent this possibility, use the VisualStudioIntegration.LogCallback event to cooperate with VSTU.


How to share the Unity Log Callback created by Visual Studio Tools for Unity.


using System;

using UnityEngine;
using UnityEditor;

using SyntaxTree.VisualStudio.Unity.Bridge;

public class LogCallbackHook
    static LogCallbackHook()
        VisualStudioIntegration.LogCallback += (string condition, string trace, LogType type) =>
            // place code that implements your log callback here

See also

Example: Project file generation