• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by miyo95 · Jul 24, 2018 at 06:59 PM · networkingcommand-linecommand line

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






Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

128 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to execute async method in batchmode correctly?,Questions about how to execute async method in batchmode 1 Answer

What minimum version of Unity supports command-line login on Mac OS,What minimum version of Unity do I need to be able to login via command-line? 0 Answers

Unity networking tutorial? 6 Answers

Analytics not found when building from command line 1 Answer

Unet: Pass player script component from client to server 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges