Inheritance: MonoBehaviour
コード例 #1
0
 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");
     }
 }
コード例 #2
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);
        }