// Use this for initialization
        void Start()
        {
            if (networkManager == null && FindObjectsOfType <VRTracker.Network.VRT_NetworkManager>().Length > 0)
            {
                networkManager = FindObjectsOfType <VRTracker.Network.VRT_NetworkManager>()[0];
            }

            playersBoundary = new List <VRT_PlayerBoundaryRenderer> ();

            if (playerNetworkIdentity == null)
            {
                playerNetworkIdentity = GetComponentInParent <NetworkIdentity> ();
            }

            if (!playerNetworkIdentity.isLocalPlayer)
            {
                return;
            }

            networkManager.OnPlayerJoin  += OnPlayerJoin;
            networkManager.OnPlayerLeave += OnPlayerLeave;

            if (playerBoundary == null)
            {
                playerBoundary = gameObject.GetComponent <VRT_PlayerBoundaryRenderer> ();
            }

            if (playerBoundary == null)
            {
                Debug.LogError("The player does not have a PlayerBoundaryRenderer");
            }

            FindPlayersBoundary();
        }
예제 #2
0
        // Use this for initialization
        void Start()
        {
            networkDiscovery = FindObjectOfType <VRTracker.Network.VRT_NetworkDiscovery>();
            networkManager   = FindObjectOfType <VRTracker.Network.VRT_NetworkManager>();


            // Check for file configuration for the Host Settings
            if (VRTracker.Configuration.VRT_FileSettings.Instance != null)
            {
                if (VRTracker.Configuration.VRT_FileSettings.Instance.host_set)
                {
                    host = VRTracker.Configuration.VRT_FileSettings.Instance.host;
                }
            }

            // Either we use the Network Discovery if enabled...
            if (networkDiscovery != null && networkDiscovery.enabled)
            {
                if (host && VRT_Manager.Instance.spectator)
                {
                    Debug.LogError("NETWORK: Cannot be host (VRT_NetworkAutoStart) and Spectator (VRT_Manager)");
                }
                else if (VRT_Manager.Instance.spectator)
                {
                    networkManager.StartLanServer();
                    networkDiscovery.StartBroadcast();
                }
                else if (host)
                {
                    networkManager.StartLanHost();
                    networkDiscovery.StartBroadcast();
                }
                else
                {
                    StartCoroutine(WaitForLanBoradcast());
                }
            }

            // ...Or we use the Gateway to get Server IP
            else
            {
                if (VRT_Manager.Instance.spectator && host)
                {
                    Debug.LogError("NETWORK: Cannot be host (VRT_NetworkAutoStart) and Spectator (VRT_Manager)");
                }
                else if (VRT_Manager.Instance.spectator)
                {
                    networkManager.StartLanServer();
                }
                else if (host)
                {
                    networkManager.StartLanHost();
                }
                else
                {
                    StartCoroutine(WaitForServerIP());
                }
            }
        }
예제 #3
0
        // Use this for initialization
        void Start()
        {
            if (networkManager == null)
            {
                networkManager = FindObjectOfType <VRTracker.Network.VRT_NetworkManager>();
            }
            if (networkManager == null)
            {
                Debug.LogError("Network Manager not found");
            }


#if (VRTACKER_INTERNAL)
            VRT_PlayerInstance localPlayer = this.gameObject.GetComponent <VRT_PlayerInstanceExtended> ();
#else
            VRT_PlayerInstance localPlayer = this.gameObject.GetComponent <VRT_PlayerInstance>();
#endif
            networkManager.AddPlayer(localPlayer);

            if (this.gameObject.GetComponent <NetworkIdentity> ().isLocalPlayer)
            {
                networkManager.SetLocalPlayer(localPlayer);
            }
        }