Jump to content

  • Log In with Google      Sign In   
  • Create Account

Launching the game with predeterminated arguments


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Grendert   Members   -  Reputation: 108

Like
0Likes
Like

Posted 20 March 2014 - 10:29 AM

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!



Sponsor:

#2 ProtectedMode   Members   -  Reputation: 1213

Like
1Likes
Like

Posted 20 March 2014 - 01:05 PM

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.



#3 ferrous   Members   -  Reputation: 2007

Like
0Likes
Like

Posted 20 March 2014 - 02:57 PM

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.



#4 frob   Moderators   -  Reputation: 21297

Like
2Likes
Like

Posted 20 March 2014 - 07:59 PM


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.


Check out my personal indie blog at bryanwagstaff.com.

#5 Grendert   Members   -  Reputation: 108

Like
0Likes
Like

Posted 23 March 2014 - 05:57 AM

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



#6 ferrous   Members   -  Reputation: 2007

Like
0Likes
Like

Posted 28 March 2014 - 01:57 PM

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.


Edited by ferrous, 28 March 2014 - 01:57 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS