Share the Unity Log Callback with VSTU

Visual Studio 2015
 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

For the latest documentation on Visual Studio 2017, see Share the Unity Log Callback with VSTU on docs.microsoft.com. 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;  
  
[InitializeOnLoad]  
public class LogCallbackHook  
{  
    static LogCallbackHook()  
    {  
        VisualStudioIntegration.LogCallback += (string condition, string trace, LogType type) =>  
        {  
            // place code that implements your log callback here  
        };  
    }  
}  

Example: Project File Generation

Show: