Beispiel #1
0
        protected override void Awake()
        {
            // If instance of the server is already running
            if (Instance != null)
            {
                // Destroy, if this is not the first instance
                Destroy(gameObject);
                return;
            }

            // Create new instance
            Instance = this;

            // Move to root, so that it won't be destroyed
            // In case this MSF instance is a child of another gameobject
            if (transform.parent != null)
            {
                transform.SetParent(null);
            }

            // Set server behaviour to be able to use in all levels
            DontDestroyOnLoad(gameObject);

            // If master IP is provided via cmd arguments
            serverIP = Mst.Args.AsString(Mst.Args.Names.MasterIp, serverIP);
            // If master port is provided via cmd arguments
            serverPort = Mst.Args.AsInt(Mst.Args.Names.MasterPort, serverPort);

            base.Awake();
        }
Beispiel #2
0
        protected override void Awake()
        {
            // If instance of the server is already running
            if (Instance != null)
            {
                // Destroy, if this is not the first instance
                Destroy(gameObject);
                return;
            }

            // Create new instance
            Instance = this;

            // Move to root, so that it won't be destroyed
            // In case this MSF instance is a child of another gameobject
            if (transform.parent != null)
            {
                transform.SetParent(null);
            }

            // Set server behaviour to be able to use in all levels
            DontDestroyOnLoad(gameObject);

            // Check is command line argument '-msfMasterPort' is defined
            if (Mst.Args.IsProvided(Mst.Args.Names.MasterIp))
            {
                serverIP = Mst.Args.MasterIp;
            }

            // Check is command line argument '-msfMasterPort' is defined
            if (Mst.Args.IsProvided(Mst.Args.Names.MasterPort))
            {
                serverPort = Mst.Args.MasterPort;
            }

            base.Awake();
        }