- Home /
Filetype association
Lets say I want to save data from the game out to a custom filetype. We'll call this ".cft". How can I make it so that I can open my game from that filetype. I can go to preferences on that file and change what application it opens with to my game, but how do I know within c# from Unity that the game was launched from this file? Also, if the game is already running and I double click this file, it will open a new instance of the game, when I want it to open in the current instance.
How would I go about doing this?
Ok so I've figured out that I can check the System.Environment.GetCommandLineArgs() to see what file has been passed into the application when opening it. I've also figured out that I can set the application to force single instance through the player settings. I'm still having the issue where I can't know what file was opened if I double-click it while the game is already running. Ideally, I would want something like StartupNextInstance from Windows Forms. Any ideas how I can get this to work? Is there something similar to this event in Unity?
Still looking for a non-Windows Forms solution for an event when someone opens a file associated with the current application. Windows Forms has a great event for when someone tries to open the application but it fails due to forcing a single instance. I'd love for an equivalent in Unity or .NET without needing Windows Forms