Skip to content

Instantly share code, notes, and snippets.

@sailro
Last active April 26, 2022 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sailro/8b51739545011e607b333b37040171d7 to your computer and use it in GitHub Desktop.
Save sailro/8b51739545011e607b333b37040171d7 to your computer and use it in GitHub Desktop.
Mimic Unity Player Announce
using System;
using System.Threading;
using SyntaxTree.VisualStudio.Unity.Messaging;
// copy SyntaxTree.VisualStudio.Unity.Messaging.dll along with Program.cs
// on mac you can find it here: /Applications/Visual\ Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.Unity/SyntaxTree.VisualStudio.Unity.Messaging.dll
// compile with: csc Program.cs -r:SyntaxTree.VisualStudio.Unity.Messaging.dll
// depending on the VSTU/VSTUM version, you will need to add -r:netstandard.dll
namespace Announce
{
internal class Program
{
static void Main(string[] args)
{
var player = new UnityPlayer
{
DebuggerPort = 56999,
Machine = "mydevbox",
ProjectName = "foo",
Debug = true,
//EditorId = 0,
Flags = UnityPlayerFlags.DevelopmentBuild | UnityPlayerFlags.ScriptDebugging,
//Guid = 0,
//Id = 0,
Ip = "192.168.1.1",
//PackageName = "",
//Port = 0,
//Version = 0,
};
if (!UnityPlayerProbe.TryCreate(out var probe))
{
Console.WriteLine("Unable to create probe");
return;
}
using (probe)
{
Console.WriteLine("Announcing... Press a key to exit...");
var running = true;
while (running)
{
probe.Announce(player);
Thread.Sleep(1000);
running = !Console.KeyAvailable;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment