Quantcast
Channel: Questions in topic: "command line"
Viewing all articles
Browse latest Browse all 123

Sharing a variable from command line with clients [C#][Unity]

$
0
0
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(); }

Viewing all articles
Browse latest Browse all 123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>