This may actually be impossible, but i’m trying to make something of a game console on a dvd in unity. When you open the console, it reads if there is a certain named USB flash drive connected to the PC, and if there is, it runs the game. So is there any way to make unity check if a named USB drive (Let’s just say it’s called “GAMEs”) in one of the PC’s ports? And if you can, is there any way to run an exe file in the certain path from C:? like C:\GAMEs\game1\game.exe? Plz help
This is more of a mono/.net question.
Here’s how you start a process in mono/.net:
As for listing usb devices… that is going to be more OS specific. Here’s a way with System.Management for Win32 systems:
http://csharphelper.com/blog/2012/09/list-usb-devices-on-the-system-in-c/
Thank you, but how do you specifically check if there is a USB named something like “GAMEs” connected and is a valid path, like something like this
if //codetocheckifausbisconnected ("GAMEs") {
//codetoopengame
}
Just do you know, I am on Windows
Disclaimer… I haven’t actually done this and am not sure it works, so if it doesn’t work… sorry… but ignoring that…
Try using System.IO.DriveInfo.GetDrives() which returns a DriveInfo array, of which you need to search through checking all the DriveInfo.VolumeLabel properties if they match your “GAMEs” label. After you find a match, the DriveInfo.Name property is probably useful as it will contain the drive letter assigned to the USB drive ("E:" or something like that I believe) which you’ll probably need before launching the games.
To start a process use:
System.Diagnostics.Process.Start
Okay, thank you!
Hey just note that most of the links I included were for the .net framework v3.5 version, which I think is what Unity still uses. There’s a lot more info if you switch them to “current version” but I don’t know if Unity includes everything you see there.