- Home /
Sharing a variable from command line with clients [C#][Unity]
Hello, so I've made an FPS and for a study, I need to change the frame rate of the clients. I currently execute the game from the command line and pass an argument -fps to set the frame rate I want. The thing is I also pass the port on which the server will listen (It's actually a host/client scenario). I need to set de Application.targetFrameRate on the clients that connect to that server, so is there a way for them to access that variable? I'm using a custom NetworkManager that derives from the Unity NetworkManager so I can't use [SyncVar] or RPC calls that derive from NetworkBehaviour, right? I currently execute this like blabla.exe -server -port 7778 -fps 30
public class NetworkManager_Custom : NetworkManager {
[SerializeField]
GameObject menuPanel;
string[] args = System.Environment.GetCommandLineArgs();
string _port = "";
string _IPAddress = "";
string _fps = "";
public int fps;
// Use this for initialization
void Start()
{
if (args != null)
{
for (int i = 0; i < args.Length; i++)
{
if (args[i] == "-port")
{
_port = args[i + 1].ToString();
//System.Console.WriteLine("lePuerto es " + _port);
Debug.Log("lePuerto es " + _port);
}
if (args[i] == "-ip")
{
_IPAddress = args[i + 1].ToString();
//System.Console.WriteLine("leIP es " + _IPAddress);
Debug.Log("leip es " + _IPAddress);
}
if (args[i] == "-fps")
{
_fps = args[i + 1].ToString();
//System.Console.WriteLine("leIP es " + _IPAddress);
Debug.Log("fps es " + _fps);
}
//Application.targetFrameRate = 60;
}
//System.Array.IndexOf(args, "-server") >=0
if (args.Contains("-server"))
{
HostGame();
//Debug.Log("fps es " + _fps);
//NetworkManager.singleton.networkPort = int.Parse(port);
//NetworkManager.singleton.serverBindAddress = IPAddress;
//NetworkManager.singleton.serverBindToIP = true;
//NetworkManager.singleton.StartServer();
}
Your answer
Follow this Question
Related Questions
Choose screen with Command line arguments 2 Answers
Windows command line returns 0 for compile errors in jenkins, 0 Answers
Class could not be found when executing method from command line (-executeMethod) 0 Answers
Simultaneous Unity & Command Prompt? 0 Answers
sign apk from jenkins/commandline,how to sign android apk through jenkins/command line 0 Answers