Launching the game with predeterminated arguments

Started by
4 comments, last by ferrous 10 years, 1 month ago

Hello!

I've depeloped an application in C++ using CEGUI that works similar than steam or the league of legends launcher.

You have your account to enter, add your friends inside the application and then you can play a game with one friend by inviting him to the game.

The game has been developed on unity.

My question is, how can I launch my unity game giving it the right parameters from my C++ Code to make that it starts the game with you and your friend just like games like league of legends, or DOTA does?

Any tutorial, guide, or something that point me in the right direction, because I really don't know where should I start.

Thanks very much!

Advertisement

You can just execute the executable with some arguments using C++ very easily (in the worst case even using system()).

I'm not an expert at C#, but if I'm right you can use C# to retrieve the command line arguments and act accordingly on the Game/Unity-side.

I have not looked into launching unity with arguments, not sure it supports it.

Unity has a player settings class, is there a way to access it outside of Unity itself?

Another way to do it, is to save the stuff you have from the launcher to a file, and then read that file in Unity. It's a bit roundabout, but if the file is small enough it should be fairly quick.


My question is, how can I launch my unity game giving it the right parameters from my C++ Code to make that it starts the game with you and your friend just like games like league of legends, or DOTA does?

You will need to put on whatever parameters you want when you call it. Command line options are one frequent option. Creating a custom environment and adding environment variables is another more clandestine method.

As Unity gives you access to the .net runtime, as ProtectedMode states two posts above you use the System.Environment functions to access your command line, your environment variables, or other methods you might consider to pass messages to the game.

Thanks for the quick response!

I've been reading and studing all your opinions, and I think that making an encripted file with the info that creates and destroys once the game reads it is the easy way to do it, and I can use that system with every single game I want to use, so, that way is more generic and that's the way I want to do it.

now I have another question, is exactly the opposite situation.

Once the game ends, I need to recover some data from it, imagine, who won, or things like that. So is simple, the game has to create a file once the game ends, and the application has to read it and handle it.

My problem is, how do I make the application to wait until the game ends? since I'm using a simple System("") to launch the application I don't know how to indicate the application to wait until the system is completed.

thanks very much

Thanks for the quick response!

I've been reading and studing all your opinions, and I think that making an encripted file with the info that creates and destroys once the game reads it is the easy way to do it, and I can use that system with every single game I want to use, so, that way is more generic and that's the way I want to do it.

now I have another question, is exactly the opposite situation.

Once the game ends, I need to recover some data from it, imagine, who won, or things like that. So is simple, the game has to create a file once the game ends, and the application has to read it and handle it.

My problem is, how do I make the application to wait until the game ends? since I'm using a simple System("") to launch the application I don't know how to indicate the application to wait until the system is completed.

thanks very much

Do you need to handle the case where the player exits the game early (alt+f4, end task, etc), or only when the player goes through the standard paths, like quitting from within the game. If the latter, just have the game launch the application. Otherwise, you might have to do some sort of process watching, launch a separate application in addition to the main game, and have it sit and look for running processes, and when the game process disappears have it do something.

This topic is closed to new replies.

Advertisement