简体   繁体   English

我可以从命令行控制C#Visual Studio(用于Unity)代码吗?

[英]Can I control C# Visual Studio (for Unity) code from the command line?

I wish to not use my Unity or Visual Studio applications at all, and either hide or show a hologram (working with Hololens here) using Command Prompt. 我不希望完全使用Unity或Visual Studio应用程序,而是使用命令提示符来隐藏或显示全息图(在此处与Hololens一起使用)。 This should be just setting a boolean true or false, but I don't want to edit the Visual Studio C# code. 这应该只是将布尔值设置为true或false,但是我不想编辑Visual Studio C#代码。

You should probably be looking at the HoloToolkit Sharing components. 您可能应该看一下HoloToolkit共享组件。

You can use a Win 10 app to control the holograms and for a simple scenario like yours it would be very simple to achieve. 您可以使用Win 10应用程序来控制全息图,对于像您这样的简单场景,将非常容易实现。 In summary, you drag a sharing prefab from HoloToolkit, you configure the server ip (localhost in your case), and you write some code to respond to whatever message you choose. 总而言之,您从HoloToolkit拖动了一个共享的预制件,配置了服务器ip(在您的情况下为localhost),并编写了一些代码以响应您选择的任何消息。

Here are some resources to get you started: 以下是一些入门资源:

  1. HoloLens Academy 240 霍洛伦斯学院240

  2. HoloToolkit Sharing GitHub Master HoloToolkit共享GitHub Master

    • check the SessionManager.UI or SessionManagerUniversal.UI projects. 检查SessionManager.UISessionManagerUniversal.UI项目。

It sounds a bit complicated, but it will open up a lot of doors in the future if you ever need to expand your solution further. 听起来有些复杂,但是如果您需要进一步扩展解决方案,它将在将来打开很多大门。

Write code that polls (checks) a file continually. 编写持续轮询(检查)文件的代码。 Like 喜欢

void Update()
{
    if(File.ReadAllText("a.txt") == "activate")
        myBool = true;
}

And change your file from commandline or whatever: 并从命令行或其他方式更改文件:

echo activate > a.txt

Note: This is just a method that requires very little changes. 注意:这只是需要很少更改的方法。 It's not the best performancewise. 这不是最好的性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM