简体   繁体   中英

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. This should be just setting a boolean true or false, but I don't want to edit the Visual Studio C# code.

You should probably be looking at the HoloToolkit Sharing components.

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. 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.

Here are some resources to get you started:

  1. HoloLens Academy 240

  2. HoloToolkit Sharing GitHub Master

    • check the SessionManager.UI or SessionManagerUniversal.UI projects.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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