Inheritance: UnityEngine.MonoBehaviour
示例#1
0
    // Use this for initialization
    void Start()
    {
        //enable 72hz mode
        OVRManager.display.displayFrequency = 72.0f;
        OVRManager.tiledMultiResLevel       = OVRManager.TiledMultiResLevel.LMSHigh;


        var manager = GameObject.Find("NetworkManager");

        networkManager = manager.GetComponent <UnityEngine.Networking.NetworkManager>();

        var canvasL = transform.Find("CanvasL");

        hostButtonL    = canvasL.Find("Host").GetComponent <UnityEngine.UI.Button>();
        offlineButtonL = canvasL.Find("Offline").GetComponent <UnityEngine.UI.Button>();
        joinButtonL    = canvasL.Find("Join").GetComponent <UnityEngine.UI.Button>();

        //right ones are just the image not button
        var canvasR = transform.Find("CanvasR");

        hostButtonR    = canvasR.Find("Host").GetComponent <UnityEngine.UI.Button>();
        offlineButtonR = canvasR.Find("Offline").GetComponent <UnityEngine.UI.Button>();
        joinButtonR    = canvasR.Find("Join").GetComponent <UnityEngine.UI.Button>();

        //joinButtonR.Select();
        //joinButtonL.Select();

        eventSystem = GameObject.Find("EventSystem").GetComponent <EventSystem>();

        eventSystem.SetSelectedGameObject(joinButtonL.gameObject);
        UpdateRightButtons();
    }
 private void Init()
 {
     if (!this.m_Initialized || (this.m_ShowGUIProperty == null))
     {
         this.m_Initialized = true;
         this.m_ManagerHud = base.target as NetworkManagerHUD;
         if (this.m_ManagerHud != null)
         {
             this.m_Manager = this.m_ManagerHud.manager;
         }
         this.m_ShowGUIProperty = base.serializedObject.FindProperty("showGUI");
         this.m_OffsetXProperty = base.serializedObject.FindProperty("offsetX");
         this.m_OffsetYProperty = base.serializedObject.FindProperty("offsetY");
         this.m_ShowServerLabel = new GUIContent("Server Info", "Details of internal server state");
         this.m_ShowServerConnectionsLabel = new GUIContent("Server Connections", "List of local and remote network connections to the server");
         this.m_ShowServerObjectsLabel = new GUIContent("Server Objects", "Networked objects spawned by the server");
         this.m_ShowClientLabel = new GUIContent("Client Info", "Details of internal client state");
         this.m_ShowClientObjectsLabel = new GUIContent("Client Objects", "Networked objects created on the client");
         this.m_ShowMatchMakerLabel = new GUIContent("MatchMaker Info", "Details about the matchmaker state");
         this.m_ShowControlsLabel = new GUIContent("Runtime Controls", "Buttons for controlling network state at runtime");
         this.m_ShowRuntimeGuiLabel = new GUIContent("Show Runtime GUI", "Show the default network control GUI when the game is running");
         this.m_OffsetXLabel = new GUIContent("GUI Horizontal Offset", "Horizontal offset of runtime GUI");
         this.m_OffsetYLabel = new GUIContent("GUI Vertical Offset", "Vertical offset of runtime GUI");
     }
 }
示例#3
0
 // Use this for initialization
 void Start()
 {
     ready.text     = "Ready";
     networkManager = UnityEngine.Networking.NetworkManager.singleton;
     if (networkManager.matchMaker == null)
     {
         networkManager.StartMatchMaker();
     }
 }
示例#4
0
        private static void DisableOnServerSceneChange(UnityEngine.Networking.NetworkManager instance, string newSceneName)
        {
            if (IsActivated)
            {
                Console.instance.SubmitCmd(LocalUserManager.GetFirstLocalUser().currentNetworkUser, "noclip");
            }

            origServerChangeScene(instance, newSceneName);
        }
示例#5
0
        private static void DisableOnClientSceneChange(UnityEngine.Networking.NetworkManager instance, string newSceneName, bool forceReload)
        {
            if (IsActivated)
            {
                Console.instance.SubmitCmd(LocalUserManager.GetFirstLocalUser().currentNetworkUser, "noclip");
            }

            origClientChangeScene(instance, newSceneName, forceReload);
        }
示例#6
0
        void Start()
        {
            networkManager = UnetManager.singleton;

            if (networkManager.matchMaker == null)
            {
                networkManager.StartMatchMaker();
            }
        }
示例#7
0
        protected override void Awake()
        {
            base.Awake();

            networkManager = NetworkManager.singleton;
            if (networkManager == null)
            {
                Debug.Log(string.Format("NetworkManager failed to load."));
            }
        }
 void Start()
 {
     s_Singleton = this;
     SetupMigrationManager(migrationManager);
     DontDestroyOnLoad(gameObject);
     foreach (GameObject obj in objectsToLoad)
     {
         ClientScene.RegisterPrefab(obj);
     }
 }
 public void Awake()
 {
     this.manager = GetComponent<NetworkManager>();
     this.style = new GUIStyle();
     this.style.normal.textColor = Color.black;
     #if UNITY_WEBGL
     this.manager.useWebSockets = true;
     #else
     #endif
 }
示例#10
0
	    public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer)
	    {
	        if (lobbyPlayer == null)
	            return;

	        LobbyPlayer lp = lobbyPlayer.GetComponent<LobbyPlayer>();

	        if (lp != null)
	            GameManager.AddCharacter(gamePlayer, lp.slot, lp.playerColor, lp.nameInput.text);
	    }
示例#11
0
 // Close all connections, e.g. when exiting or aborting a game
 public void DisconnectAll()
 {
     if (manager == null)
         manager = GameObject.Find ("NetworkManager").GetComponent<NetworkManager> ();
     if (manager.isNetworkActive) {
         if (manager.client != null)
             manager.StopClient ();
         manager.StopHost ();
         Network.Disconnect ();
     }
 }
        public void Populate(MatchDesc match, NetworkManager networkManager, Color c)
        {
            serverInfoText.text = match.name;

            slotInfo.text = match.currentSize.ToString() + "/" + match.maxSize.ToString(); ;

            NetworkID networkID = match.networkId;

            joinButton.onClick.RemoveAllListeners();
            joinButton.onClick.AddListener(() => { JoinMatch(networkID, networkManager); });
        }
示例#13
0
        public static void CopySpawnablePrefabs(UnityEngine.Networking.NetworkManager src, Mirror.NetworkManager targ)
        {
            foreach (var obj in src.spawnPrefabs)
            {
                GiveMirrorNetworkIdentity(obj);

                if (!targ.spawnPrefabs.Contains(obj))
                {
                    targ.spawnPrefabs.Add(obj);
                }
            }
        }
示例#14
0
        public static void CopyPlayerPrefab(UnityEngine.Networking.NetworkManager src, Mirror.NetworkManager targ)
        {
            /// Make sure the player object is using mirror components
            if (src.playerPrefab)
            {
                GiveMirrorNetworkIdentity(src.playerPrefab);

                targ.autoCreatePlayer = src.autoCreatePlayer;
                targ.playerPrefab     = src.playerPrefab;
                var ppNI = targ.playerPrefab.GetComponent <NetworkIdentity>();
                ppNI.localPlayerAuthority = true;
            }
        }
 void JoinMatch(NetworkID networkID, NetworkManager networkManager)
 {
     networkManager.matchMaker.JoinMatch(networkID, "", networkManager.OnMatchJoined);
 }
示例#16
0
 public static void Shutdown()
 {
     if (singleton != null)
     {
         s_StartPositions.Clear();
         s_StartPositionIndex = 0;
         s_ClientReadyConnection = null;
         singleton.StopHost();
         singleton = null;
     }
 }
 /// <summary>
 ///   <para>Shuts down the NetworkManager completely and destroy the singleton.</para>
 /// </summary>
 public static void Shutdown()
 {
   if ((UnityEngine.Object) NetworkManager.singleton == (UnityEngine.Object) null)
     return;
   NetworkManager.s_StartPositions.Clear();
   NetworkManager.s_StartPositionIndex = 0;
   NetworkManager.s_ClientReadyConnection = (NetworkConnection) null;
   NetworkManager.singleton.StopHost();
   NetworkManager.singleton = (NetworkManager) null;
 }
 private void InitializeSingleton()
 {
   if ((UnityEngine.Object) NetworkManager.singleton != (UnityEngine.Object) null && (UnityEngine.Object) NetworkManager.singleton == (UnityEngine.Object) this)
     return;
   LogFilter.currentLogLevel = (int) this.m_LogLevel;
   if (this.m_DontDestroyOnLoad)
   {
     if ((UnityEngine.Object) NetworkManager.singleton != (UnityEngine.Object) null)
     {
       if (LogFilter.logDev)
         Debug.Log((object) "Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will not be used.");
       UnityEngine.Object.Destroy((UnityEngine.Object) this.gameObject);
       return;
     }
     if (LogFilter.logDev)
       Debug.Log((object) "NetworkManager created singleton (DontDestroyOnLoad)");
     NetworkManager.singleton = this;
     UnityEngine.Object.DontDestroyOnLoad((UnityEngine.Object) this.gameObject);
   }
   else
   {
     if (LogFilter.logDev)
       Debug.Log((object) "NetworkManager created singleton (ForScene)");
     NetworkManager.singleton = this;
   }
   if (this.m_NetworkAddress != string.Empty)
   {
     NetworkManager.s_Address = this.m_NetworkAddress;
   }
   else
   {
     if (!(NetworkManager.s_Address != string.Empty))
       return;
     this.m_NetworkAddress = NetworkManager.s_Address;
   }
 }
示例#19
0
 public void Awake()
 {
     NetworkManager.RegisterStartPosition(base.transform);
 }
示例#20
0
 public void OnDestroy()
 {
     NetworkManager.UnRegisterStartPosition(base.transform);
 }
示例#21
0
 private void InitializeSingleton()
 {
     if ((singleton == null) || (singleton != this))
     {
         LogFilter.currentLogLevel = (int) this.m_LogLevel;
         if (this.m_DontDestroyOnLoad)
         {
             if (singleton != null)
             {
                 if (LogFilter.logDev)
                 {
                     Debug.Log("Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will not be used.");
                 }
                 UnityEngine.Object.Destroy(base.gameObject);
                 return;
             }
             if (LogFilter.logDev)
             {
                 Debug.Log("NetworkManager created singleton (DontDestroyOnLoad)");
             }
             singleton = this;
             if (Application.isPlaying)
             {
                 UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
             }
         }
         else
         {
             if (LogFilter.logDev)
             {
                 Debug.Log("NetworkManager created singleton (ForScene)");
             }
             singleton = this;
         }
         if (this.m_NetworkAddress != "")
         {
             s_Address = this.m_NetworkAddress;
         }
         else if (s_Address != "")
         {
             this.m_NetworkAddress = s_Address;
         }
     }
 }
 private void Awake()
 {
     this.manager = base.GetComponent<NetworkManager>();
 }
示例#23
0
 // Use this for initialization
 void Start()
 {
     nm = GetComponent <UnityEngine.Networking.NetworkManager> ();
 }
示例#24
0
		void Awake()
		{
			manager = GetComponent<NetworkManager>();
		}
示例#25
0
        void Awake()
        {
            this.character = GameObject.Find("CharacterModel");
            this.loadingImage = Resources.Load<Texture>("Sprites/SplashImages/LoadingImage");

            this.incr = Random.Range(-0.02f, 0.02f);
            this.incg = Random.Range(-0.02f, 0.02f);
            this.incb = Random.Range(-0.02f, 0.02f);
            this.manager = GetComponent<NetworkManager>();
            this.skin = Resources.Load<GUISkin>("Sprites/GUIskin/skin");
            this.skin.GetStyle("chat").fontSize = (int)(Screen.height * 0.025f);
            this.skin.GetStyle("chat").alignment = TextAnchor.MiddleCenter;
            this.skin.GetStyle("chat").fontStyle = FontStyle.Bold;
            this.skin.textField.fontSize = (int)(Screen.height * 0.025f);
            this.skin.textField.fontStyle = FontStyle.Bold;

            this.skin.GetStyle("button").fontSize = (int)(Screen.height * 0.025f);
            this.posX = (int)(Screen.width / 2.6f);
            this.posY = (int)(Screen.height / 2.5f);
            this.width = Screen.width / 4;
            this.height = Screen.height / 30;
            this.spacing = this.height * 2;
            this.playerName = PlayerPrefs.GetString("PlayerName", "");
            SystemLanguage langue = PlayerPrefs.GetInt("langue", 1) == 1 ? SystemLanguage.English : SystemLanguage.French;
            this.categoryCloth = CategoryCloth.None;
            Text.SetLanguage(langue);
            this.firstScene = GameObject.Find("Map").GetComponent<FirstScene>();

            if (!Directory.Exists(Application.dataPath + "/Saves"))
                Directory.CreateDirectory(Application.dataPath + "/Saves");
            this.skin.GetStyle("loading").normal.textColor = Color.black;

            try
            {
                string skintStr = PlayerPrefs.GetString("Skin", "");
                this.skinCharacter = Skin.Load(skintStr);
                this.skinCharacter.ForceApply(this.character);
            }
            catch
            {
                this.characterShown = true;
                this.skinCharacter = new Skin(Clothing.NormalBrownBeard, Clothing.NormalBrownHair, Clothing.NoneHat, Clothing.BasicBody, Clothing.NoneTshirt, Clothing.BrownOveralls, Clothing.BrownGloves, Clothing.BlackEye);
                this.skinCharacter.ForceApply(this.character);
            }
        }
示例#26
0
 public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer)
 {
     ConnectingPlayer connectingPlayer = lobbyPlayer.GetComponent<ConnectingPlayer>();
 }
示例#27
0
 // Use this for initialization
 void Start()
 {
     UnityEngine.Networking.NetworkManager networkManager = GetComponent <UnityEngine.Networking.NetworkManager>();
     networkManager.StartClient();
 }
示例#28
0
 private void Awake()
 {
     LogFilter.currentLogLevel = (int) this.m_LogLevel;
     if (this.m_DontDestroyOnLoad)
     {
         if (singleton != null)
         {
             if (LogFilter.logWarn)
             {
                 Debug.LogWarning("Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will not be used.");
             }
             UnityEngine.Object.Destroy(base.gameObject);
             return;
         }
         if (LogFilter.logDev)
         {
             Debug.Log("NetworkManager created singleton (DontDestroyOnLoad)");
         }
         singleton = this;
         UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
     }
     else
     {
         if (LogFilter.logDev)
         {
             Debug.Log("NetworkManager created singleton (ForScene)");
         }
         singleton = this;
     }
     if (this.m_NetworkAddress != string.Empty)
     {
         s_Address = this.m_NetworkAddress;
     }
     else if (s_Address != string.Empty)
     {
         this.m_NetworkAddress = s_Address;
     }
 }
示例#29
0
        public static Mirror.NetworkManager ConvertNetworkManager(UnityEngine.Networking.NetworkManager unetNM, UnityEngine.Networking.NetworkManagerHUD unetHUD)
        {
            if (unetNM == null)
            {
                return(null);
            }

            var go = unetNM.gameObject;

            Mirror.NetworkManager mirrorNM = null;

            /// If this has a UNET NM on it, replace it with Mirror, and copy the playerprefab over
            if (unetNM)
            {
                var transport = go.GetComponent <Transport>();
                if (!transport)
                {
                    transport = go.AddComponent <TelepathyTransport>();
                }

                mirrorNM = go.GetComponent <Mirror.NetworkManager>();
                if (mirrorNM == null)
                {
                    mirrorNM = go.AddComponent <Mirror.NetworkManager>();
                    NetworkManager.singleton = mirrorNM;
                }

                var mirrorHUD = go.GetComponent <Mirror.NetworkManagerHUD>();
                if (mirrorHUD == null)
                {
                    mirrorHUD = go.AddComponent <Mirror.NetworkManagerHUD>();
                }

#if MIRROR_1726_OR_NEWER
                /// Initialize some stuff Mirror doesn't on its own (at least when this was written)
                Transport.activeTransport = transport;
                Transport.activeTransport.OnServerDisconnected = new UnityEventInt();
                Transport.activeTransport.OnServerConnected    = new UnityEventInt();
                Transport.activeTransport.OnServerDataReceived = new UnityEventIntByteArray();
                Transport.activeTransport.OnServerError        = new UnityEventIntException();
                Transport.activeTransport.OnClientConnected    = new UnityEngine.Events.UnityEvent();
                Transport.activeTransport.OnClientDataReceived = new UnityEventByteArray();
                Transport.activeTransport.OnClientError        = new UnityEventException();
                Transport.activeTransport.OnClientDisconnected = new UnityEngine.Events.UnityEvent();
#else
                /// Initialize some stuff Mirror doesn't on its own (Fix this Mirror team)
                NetworkManager.singleton.transport = transport;
                NetworkManager.singleton.transport.OnServerDisconnected = new UnityEventInt();
                NetworkManager.singleton.transport.OnServerConnected    = new UnityEventInt();
                NetworkManager.singleton.transport.OnServerDataReceived = new UnityEventIntByteArray();
                NetworkManager.singleton.transport.OnServerError        = new UnityEventIntException();
                NetworkManager.singleton.transport.OnClientConnected    = new UnityEngine.Events.UnityEvent();
                NetworkManager.singleton.transport.OnClientDataReceived = new UnityEventByteArray();
                NetworkManager.singleton.transport.OnClientError        = new UnityEventException();
                NetworkManager.singleton.transport.OnClientDisconnected = new UnityEngine.Events.UnityEvent();
#endif // End Mirror_1726

                /// Destroy the Unet HUD

                if (unetHUD)
                {
                    Object.DestroyImmediate(unetHUD, true);
                }

                /// Copy values from UNET NM to Mirror NM
                if (unetNM)
                {
                    CopyPlayerPrefab(unetNM, mirrorNM);
                    CopySpawnablePrefabs(unetNM, mirrorNM);
                    Object.DestroyImmediate(unetNM, true);
                }
            }

            Object.DestroyImmediate(unetHUD, true);
            Object.DestroyImmediate(unetNM, true);

            UnityEditor.SceneManagement.EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
            return(mirrorNM);
        }
 protected void Init()
 {
     if (!this.m_Initialized)
     {
         this.m_Initialized = true;
         this.m_NetworkManager = base.target as NetworkManager;
         this.m_ShowNetworkLabel = new GUIContent("Network Info", "Network host names and ports");
         this.m_ShowSpawnLabel = new GUIContent("Spawn Info", "Registered spawnable objects");
         this.m_OfflineSceneLabel = new GUIContent("Offline Scene", "The scene loaded when the network goes offline (disconnected from server)");
         this.m_OnlineSceneLabel = new GUIContent("Online Scene", "The scene loaded when the network comes online (connected to server)");
         this.m_DontDestroyOnLoadLabel = new GUIContent("Dont Destroy On Load", "Persist the network manager across scene changes.");
         this.m_RunInBackgroundLabel = new GUIContent("Run in Background", "This ensures that the application runs when it does not have focus. This is required when testing multiple instances on a single machine, but not recommended for shipping on mobile platforms.");
         this.m_ScriptCRCCheckLabel = new GUIContent("Script CRC Check", "Enables a CRC check between server and client that ensures the NetworkBehaviour scripts match. This may not be appropriate in some cases, such a when the client and server are different Unity projects.");
         this.m_MaxConnectionsLabel = new GUIContent("Max Connections", "Maximum number of network connections");
         this.m_MinUpdateTimeoutLabel = new GUIContent("Min Update Timeout", "Minimum time network thread waits for events");
         this.m_ConnectTimeoutLabel = new GUIContent("Connect Timeout", "Time to wait for timeout on connecting");
         this.m_DisconnectTimeoutLabel = new GUIContent("Disconnect Timeout", "Time to wait for detecting disconnect");
         this.m_PingTimeoutLabel = new GUIContent("Ping Timeout", "Time to wait for ping messages");
         this.m_ThreadAwakeTimeoutLabel = new GUIContent("Thread Awake Timeout", "The minimum time period when system will check if there are any messages for send (or receive).");
         this.m_ReactorModelLabel = new GUIContent("Reactor Model", "Defines reactor model for the network library");
         this.m_ReactorMaximumReceivedMessagesLabel = new GUIContent("Reactor Max Recv Messages", "Defines maximum amount of messages in the receive queue");
         this.m_ReactorMaximumSentMessagesLabel = new GUIContent("Reactor Max Sent Messages", "Defines maximum message count in sent queue");
         this.m_MaxBufferedPacketsLabel = new GUIContent("Max Buffered Packets", "The maximum number of packets that can be buffered by a NetworkConnection for each channel. This corresponds to the 'ChannelOption.MaxPendingBuffers' channel option.");
         this.m_AllowFragmentationLabel = new GUIContent("Packet Fragmentation", "This allow NetworkConnection instances to fragment packets that are larger than the maxPacketSize, up to a maximum of 64K. This can cause delays in sending large packets, but is usually preferable to send failures.");
         this.m_UseWebSocketsLabel = new GUIContent("Use WebSockets", "This makes the server listen for connections using WebSockets. This allows WebGL clients to connect to the server.");
         this.m_UseSimulatorLabel = new GUIContent("Use Network Simulator", "This simulates network latency and packet loss on clients. Useful for testing under internet-like conditions");
         this.m_LatencyLabel = new GUIContent("Simulated Average Latency", "The amount of delay in milliseconds to add to network packets");
         this.m_PacketLossPercentageLabel = new GUIContent("Simulated Packet Loss", "The percentage of packets that should be dropped");
         this.m_MatchHostLabel = new GUIContent("MatchMaker Host URI", "The URI for the MatchMaker.");
         this.m_MatchPortLabel = new GUIContent("MatchMaker Port", "The port for the MatchMaker.");
         this.m_MatchNameLabel = new GUIContent("Match Name", "The name that will be used when creating a match in MatchMaker.");
         this.m_MatchSizeLabel = new GUIContent("Maximum Match Size", "The maximum size for the match. This value is compared to the maximum size specified in the service configuration at multiplayer.unity3d.com and the lower of the two is enforced. It must be greater than 1. This is typically used to override the match size for various game modes.");
         this.m_DontDestroyOnLoadProperty = base.serializedObject.FindProperty("m_DontDestroyOnLoad");
         this.m_RunInBackgroundProperty = base.serializedObject.FindProperty("m_RunInBackground");
         this.m_ScriptCRCCheckProperty = base.serializedObject.FindProperty("m_ScriptCRCCheck");
         this.m_LogLevelProperty = base.serializedObject.FindProperty("m_LogLevel");
         this.m_NetworkAddressProperty = base.serializedObject.FindProperty("m_NetworkAddress");
         this.m_NetworkPortProperty = base.serializedObject.FindProperty("m_NetworkPort");
         this.m_ServerBindToIPProperty = base.serializedObject.FindProperty("m_ServerBindToIP");
         this.m_ServerBindAddressProperty = base.serializedObject.FindProperty("m_ServerBindAddress");
         this.m_MaxDelayProperty = base.serializedObject.FindProperty("m_MaxDelay");
         this.m_MaxBufferedPacketsProperty = base.serializedObject.FindProperty("m_MaxBufferedPackets");
         this.m_AllowFragmentationProperty = base.serializedObject.FindProperty("m_AllowFragmentation");
         this.m_MatchHostProperty = base.serializedObject.FindProperty("m_MatchHost");
         this.m_MatchPortProperty = base.serializedObject.FindProperty("m_MatchPort");
         this.m_MatchNameProperty = base.serializedObject.FindProperty("matchName");
         this.m_MatchSizeProperty = base.serializedObject.FindProperty("matchSize");
         this.m_PlayerPrefabProperty = base.serializedObject.FindProperty("m_PlayerPrefab");
         this.m_AutoCreatePlayerProperty = base.serializedObject.FindProperty("m_AutoCreatePlayer");
         this.m_PlayerSpawnMethodProperty = base.serializedObject.FindProperty("m_PlayerSpawnMethod");
         this.m_SpawnListProperty = base.serializedObject.FindProperty("m_SpawnPrefabs");
         this.m_SpawnList = new ReorderableList(base.serializedObject, this.m_SpawnListProperty);
         if (<>f__mg$cache0 == null)
         {
示例#31
0
 void Awake()
 {
     manager = GetComponent <NetworkManager>();
 }
 void Awake()
 {
     manager = GetComponent<NetworkManager>();
     canv = GameObject.Find ("Canvas");
 }
 public override void OnLobbyServerSceneLoadedForPlayer(UnityEngine.Networking.NetworkManager manager,
                                                        GameObject lobbyPlayer, GameObject gamePlayer)
 {
     LobbyPlayer I = lobbyPlayer.GetComponent <LobbyPlayer> ();
     //PlayerBoard playerB = gamePlayer.GetComponent<PlayerBoard> ();
 }
示例#34
0
 void Start()
 {
     manager = GetComponent<NetworkManager> ();
     imageTarget = null;
 }
示例#35
0
 void Awake()
 {
     manager = GetComponent<NetworkManager>();
     networkAddress.text = "Start Client: " + manager.networkAddress;
 }
示例#36
0
        private void Awake()
        {
            LogFilter.currentLogLevel = (int) this.m_LogLevel;

              if (this.m_DontDestroyOnLoad)
              {
              // Reinforce the singleton idea in awake by deleting a copy if made
            if ((UnityEngine.Object) NetworkManager.singleton != (UnityEngine.Object) null)
            {
              if (LogFilter.logDebug)
            Debug.Log((object) "NetworkManager created but singleton already exists");

              UnityEngine.Object.Destroy((UnityEngine.Object) this.gameObject);
              return;
            }

            if (LogFilter.logDev)
              Debug.Log((object) "NetworkManager created singleton (DontDestroyOnLoad)");

            NetworkManager.singleton = this; // set the singleton field for the network game
            UnityEngine.Object.DontDestroyOnLoad((UnityEngine.Object) this.gameObject); // persist the same NetManager/singleton object between scenes
              }
              else // NetManager will not persist between scenes
              {
            if (LogFilter.logDev)
              Debug.Log((object) "NetworkManager created singleton (ForScene)");

            NetworkManager.singleton = this;
              }

              if (this.m_NetworkAddress != string.Empty)
              {
            NetworkManager.s_address = this.m_NetworkAddress;
              }
              else
              {
            if (!(NetworkManager.s_address != string.Empty))
              return;
            this.m_NetworkAddress = NetworkManager.s_address;
              }
        }
 protected void Init()
 {
   if (this.m_Initialized)
     return;
   this.m_Initialized = true;
   this.m_NetworkManager = this.target as NetworkManager;
   this.m_ShowNetworkLabel = new GUIContent("Network Info", "Network host names and ports");
   this.m_ShowSpawnLabel = new GUIContent("Spawn Info", "Registered spawnable objects");
   this.m_OfflineSceneLabel = new GUIContent("Offline Scene", "The scene loaded when the network goes offline (disconnected from server)");
   this.m_OnlineSceneLabel = new GUIContent("Online Scene", "The scene loaded when the network comes online (connected to server)");
   this.m_DontDestroyOnLoadLabel = new GUIContent("Dont Destroy On Load", "Persist the network manager across scene changes.");
   this.m_RunInBackgroundLabel = new GUIContent("Run in Background", "This ensures that the application runs when it does not have focus. This is required when testing multiple instances on a single machine, but not recommended for shipping on mobile platforms.");
   this.m_ScriptCRCCheckLabel = new GUIContent("Script CRC Check", "Enables a CRC check between server and client that ensures the NetworkBehaviour scripts match. This may not be appropriate in some cases, such a when the client and server are different Unity projects.");
   this.m_MaxConnectionsLabel = new GUIContent("Max Connections", "Maximum number of network connections");
   this.m_MinUpdateTimeoutLabel = new GUIContent("Min Update Timeout", "Minimum time network thread waits for events");
   this.m_ConnectTimeoutLabel = new GUIContent("Connect Timeout", "Time to wait for timeout on connecting");
   this.m_DisconnectTimeoutLabel = new GUIContent("Disconnect Timeout", "Time to wait for detecting disconnect");
   this.m_PingTimeoutLabel = new GUIContent("Ping Timeout", "Time to wait for ping messages");
   this.m_ThreadAwakeTimeoutLabel = new GUIContent("Thread Awake Timeout", "The minimum time period when system will check if there are any messages for send (or receive).");
   this.m_ReactorModelLabel = new GUIContent("Reactor Model", "Defines reactor model for the network library");
   this.m_ReactorMaximumReceivedMessagesLabel = new GUIContent("Reactor Max Recv Messages", "Defines maximum amount of messages in the receive queue");
   this.m_ReactorMaximumSentMessagesLabel = new GUIContent("Reactor Max Sent Messages", "Defines maximum message count in sent queue");
   this.m_UseWebSocketsLabel = new GUIContent("Use WebSockets", "This makes the server listen for connections using WebSockets. This allows WebGL clients to connect to the server.");
   this.m_UseSimulatorLabel = new GUIContent("Use Network Simulator", "This simulates network latency and packet loss on clients. Useful for testing under internet-like conditions");
   this.m_LatencyLabel = new GUIContent("Simulated Average Latency", "The amount of delay in milliseconds to add to network packets");
   this.m_PacketLossPercentageLabel = new GUIContent("Simulated Packet Loss", "The percentage of packets that should be dropped");
   this.m_DontDestroyOnLoadProperty = this.serializedObject.FindProperty("m_DontDestroyOnLoad");
   this.m_RunInBackgroundProperty = this.serializedObject.FindProperty("m_RunInBackground");
   this.m_ScriptCRCCheckProperty = this.serializedObject.FindProperty("m_ScriptCRCCheck");
   this.m_LogLevelProperty = this.serializedObject.FindProperty("m_LogLevel");
   this.m_NetworkAddressProperty = this.serializedObject.FindProperty("m_NetworkAddress");
   this.m_NetworkPortProperty = this.serializedObject.FindProperty("m_NetworkPort");
   this.m_ServerBindToIPProperty = this.serializedObject.FindProperty("m_ServerBindToIP");
   this.m_ServerBindAddressProperty = this.serializedObject.FindProperty("m_ServerBindAddress");
   this.m_MaxDelayProperty = this.serializedObject.FindProperty("m_MaxDelay");
   this.m_MatchHostProperty = this.serializedObject.FindProperty("m_MatchHost");
   this.m_MatchPortProperty = this.serializedObject.FindProperty("m_MatchPort");
   this.m_PlayerPrefabProperty = this.serializedObject.FindProperty("m_PlayerPrefab");
   this.m_AutoCreatePlayerProperty = this.serializedObject.FindProperty("m_AutoCreatePlayer");
   this.m_PlayerSpawnMethodProperty = this.serializedObject.FindProperty("m_PlayerSpawnMethod");
   this.m_SpawnListProperty = this.serializedObject.FindProperty("m_SpawnPrefabs");
   this.m_SpawnList = new ReorderableList(this.serializedObject, this.m_SpawnListProperty);
   this.m_SpawnList.drawHeaderCallback = new ReorderableList.HeaderCallbackDelegate(NetworkManagerEditor.DrawHeader);
   this.m_SpawnList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.DrawChild);
   this.m_SpawnList.onReorderCallback = new ReorderableList.ReorderCallbackDelegate(this.Changed);
   this.m_SpawnList.onAddDropdownCallback = new ReorderableList.AddDropdownCallbackDelegate(this.AddButton);
   this.m_SpawnList.onRemoveCallback = new ReorderableList.RemoveCallbackDelegate(this.RemoveButton);
   this.m_SpawnList.onChangedCallback = new ReorderableList.ChangedCallbackDelegate(this.Changed);
   this.m_SpawnList.onReorderCallback = new ReorderableList.ReorderCallbackDelegate(this.Changed);
   this.m_SpawnList.onAddCallback = new ReorderableList.AddCallbackDelegate(this.Changed);
   this.m_SpawnList.elementHeight = 16f;
   this.m_CustomConfigProperty = this.serializedObject.FindProperty("m_CustomConfig");
   this.m_ChannelListProperty = this.serializedObject.FindProperty("m_Channels");
   this.m_ChannelList = new ReorderableList(this.serializedObject, this.m_ChannelListProperty);
   this.m_ChannelList.drawHeaderCallback = new ReorderableList.HeaderCallbackDelegate(NetworkManagerEditor.ChannelDrawHeader);
   this.m_ChannelList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.ChannelDrawChild);
   this.m_ChannelList.onReorderCallback = new ReorderableList.ReorderCallbackDelegate(this.ChannelChanged);
   this.m_ChannelList.onAddDropdownCallback = new ReorderableList.AddDropdownCallbackDelegate(this.ChannelAddButton);
   this.m_ChannelList.onRemoveCallback = new ReorderableList.RemoveCallbackDelegate(this.ChannelRemoveButton);
   this.m_ChannelList.onChangedCallback = new ReorderableList.ChangedCallbackDelegate(this.ChannelChanged);
   this.m_ChannelList.onReorderCallback = new ReorderableList.ReorderCallbackDelegate(this.ChannelChanged);
   this.m_ChannelList.onAddCallback = new ReorderableList.AddCallbackDelegate(this.ChannelChanged);
   this.m_UseWebSocketsProperty = this.serializedObject.FindProperty("m_UseWebSockets");
   this.m_UseSimulatorProperty = this.serializedObject.FindProperty("m_UseSimulator");
   this.m_SimulatedLatencyProperty = this.serializedObject.FindProperty("m_SimulatedLatency");
   this.m_PacketLossPercentageProperty = this.serializedObject.FindProperty("m_PacketLossPercentage");
 }
 public NetworkManager()
 {
   NetworkManager.s_PendingSingleton = this;
 }
示例#39
0
 // this is invoked by the UnityEngine when a Mono Domain reload happens in the editor.
 // the transport layer has state in C++, so when the C# state is lost (on domain reload), the C++ transport layer must be shutown as well.
 static internal void UNetDomainReload()
 {
     NetworkManager.OnDomainReload();
 }
 private void GetNetworkInformation(NetworkManager man)
 {
   this.m_Manager = man;
 }
示例#41
0
 public override void OnLobbyServerSceneLoadedForPlayer(UnityEngine.Networking.NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer)
 {
     Debug.Log("Start lobby hook");
 }
示例#42
0
文件: LobbyHook.cs 项目: xenouk/Arena
		public virtual void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer, int matchMode) { }
示例#43
0
        // Use this for initialization
        void Start()
        {
            // Gather Information
            menu = transform;
            Transform buttons = menu.FindChild("Interaction").FindChild ("Buttons").transform;
            serverIP = buttons.FindChild ("ClientField").GetComponent<InputField>();
            serverPort = buttons.FindChild ("PortField").GetComponent<InputField>();
            myIP = menu.FindChild("Interaction").FindChild ("Labels").transform.FindChild ("IPAddress").GetComponent<Text> ();
            errorField = menu.FindChild ("ErrorField").gameObject;

            // Use GameObject since it's not a child of menu
            GameObject nm = GameObject.Find ("NetworkManager");

            // Avoid running multiple managers when switching scenes.
            if (null == nm) {
                if (Debug.isDebugBuild) {
                    Debug.Log ("Creating NetworkManager Singleton");
                }
                nm = (GameObject)Instantiate (networkManagerPrefab, Vector3.zero, Quaternion.identity);

            }
            networkManager = nm.GetComponent<NetworkManager>();
            networkManager.name = "NetworkManager";
            SetIPLabel(Network.player.ipAddress);
        }