Last active
April 26, 2022 15:26
-
-
Save sailro/8b51739545011e607b333b37040171d7 to your computer and use it in GitHub Desktop.
Mimic Unity Player Announce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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