Esempio n. 1
0
 private void ShowControls()
 {
     this.m_ShowControls = EditorGUILayout.Foldout(this.m_ShowControls, this.m_ShowControlsLabel);
     if (!this.m_ShowControls)
     {
         return;
     }
     if (!string.IsNullOrEmpty(NetworkManager.networkSceneName))
     {
         EditorGUILayout.ObjectField("Current Scene:", NetworkManagerHUDEditor.GetSceneObject(NetworkManager.networkSceneName), typeof(Object), true, new GUILayoutOption[0]);
     }
     EditorGUILayout.Separator();
     if (!NetworkClient.active && !NetworkServer.active && (Object)this.m_Manager.matchMaker == (Object)null)
     {
         EditorGUILayout.BeginHorizontal();
         if (GUILayout.Toggle(false, "LAN Host", EditorStyles.miniButton, new GUILayoutOption[0]))
         {
             this.m_Manager.StartHost();
         }
         if (GUILayout.Toggle(false, "LAN Server", EditorStyles.miniButton, new GUILayoutOption[0]))
         {
             this.m_Manager.StartServer();
         }
         if (GUILayout.Toggle(false, "LAN Client", EditorStyles.miniButton, new GUILayoutOption[0]))
         {
             this.m_Manager.StartClient();
         }
         if (GUILayout.Toggle(false, "Start Matchmaker", EditorStyles.miniButton, new GUILayoutOption[0]))
         {
             this.m_Manager.StartMatchMaker();
             this.m_ShowMatchMaker = true;
         }
         EditorGUILayout.EndHorizontal();
     }
     if (NetworkClient.active && !ClientScene.ready && GUI.Button(NetworkManagerHUDEditor.GetButtonRect(), "Client Ready"))
     {
         ClientScene.Ready(this.m_Manager.client.connection);
         if (ClientScene.localPlayers.Count == 0)
         {
             ClientScene.AddPlayer((short)0);
         }
     }
     if ((NetworkServer.active || NetworkClient.active) && GUI.Button(NetworkManagerHUDEditor.GetButtonRect(), "Stop"))
     {
         this.m_Manager.StopServer();
         this.m_Manager.StopClient();
     }
     if (!NetworkServer.active && !NetworkClient.active)
     {
         EditorGUILayout.Separator();
         if ((Object)this.m_Manager.matchMaker != (Object)null && this.m_Manager.matchInfo == null)
         {
             if (this.m_Manager.matches == null)
             {
                 EditorGUILayout.BeginHorizontal();
                 if (GUILayout.Toggle(false, "Create Internet Match", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.matchMaker.CreateMatch(this.m_Manager.matchName, this.m_Manager.matchSize, true, string.Empty, new NetworkMatch.ResponseDelegate <CreateMatchResponse>(this.m_Manager.OnMatchCreate));
                 }
                 if (GUILayout.Toggle(false, "Find Internet Match", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.matchMaker.ListMatches(0, 20, string.Empty, new NetworkMatch.ResponseDelegate <ListMatchResponse>(this.m_Manager.OnMatchList));
                 }
                 if (GUILayout.Toggle(false, "Stop MatchMaker", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.StopMatchMaker();
                 }
                 EditorGUILayout.EndHorizontal();
                 this.m_Manager.matchName = EditorGUILayout.TextField("Room Name:", this.m_Manager.matchName, new GUILayoutOption[0]);
                 this.m_Manager.matchSize = (uint)EditorGUILayout.IntField("Room Size:", (int)this.m_Manager.matchSize, new GUILayoutOption[0]);
                 EditorGUILayout.BeginHorizontal();
                 if (GUILayout.Toggle(false, "Use Local Relay", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.SetMatchHost("localhost", 1337, false);
                 }
                 if (GUILayout.Toggle(false, "Use Internet Relay", EditorStyles.miniButton, new GUILayoutOption[0]))
                 {
                     this.m_Manager.SetMatchHost("mm.unet.unity3d.com", 80, false);
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.Separator();
             }
             else
             {
                 using (List <MatchDesc> .Enumerator enumerator = this.m_Manager.matches.GetEnumerator())
                 {
                     while (enumerator.MoveNext())
                     {
                         MatchDesc current = enumerator.Current;
                         if (GUI.Button(NetworkManagerHUDEditor.GetButtonRect(), "Join Match:" + current.name))
                         {
                             this.m_Manager.matchName = current.name;
                             this.m_Manager.matchSize = (uint)current.currentSize;
                             this.m_Manager.matchMaker.JoinMatch(current.networkId, string.Empty, new NetworkMatch.ResponseDelegate <JoinMatchResponse>(this.m_Manager.OnMatchJoined));
                         }
                     }
                 }
                 if (GUI.Button(NetworkManagerHUDEditor.GetButtonRect(), "Stop MatchMaker"))
                 {
                     this.m_Manager.StopMatchMaker();
                 }
             }
         }
     }
     EditorGUILayout.Separator();
 }