Method group is Obsolete

NetworkLobbyManager.OnLobbyStartServer

매뉴얼로 전환
Obsolete public void OnLobbyStartServer ();

설명

This is called on the server when the server is started - including when a host is started.

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

public class Example : NetworkLobbyManager { //Add this script to your GameObject. Make sure there isn't another NetworkManager in the Scene. //Create 2 Buttons (Create>UI>Buttons) and either: //1. assign them in the Inspector of the GameObject this script is attached to or //2. remove this part and the listeners and alter the OnClick section on each Button to match up with each function //Create a Text GameObject (Create>UI>Text) and attach it to the Status Text field in the Inspector.

public Button m_ClientButton, m_ServerButton; bool m_ServerStarted, m_ClientStarted;

void Start() { showLobbyGUI = true; //Call these functions when each Button is clicked m_ServerButton.onClick.AddListener(ServerButton); m_ClientButton.onClick.AddListener(ClientButton); }

//Output a message when your client enters the lobby public override void OnLobbyClientEnter() { m_ClientStarted = true; base.OnLobbyClientEnter(); Debug.Log("Your client has entered the lobby!"); }

public override void OnLobbyStopClient() { Debug.Log("Client stopped"); base.OnLobbyStopClient(); }

public override void OnLobbyStartServer() { m_ServerStarted = true; base.OnLobbyStartServer(); Debug.Log("Server Started!"); }

public override void OnStopServer() { m_ServerStarted = false; base.OnStopServer(); Debug.Log("Server Stopped!"); }

//Start the Client when this Button is pressed public void ClientButton() { if (m_ClientStarted == false) { StartClient(); m_ClientButton.GetComponentInChildren<Text>().text = "Stop Client"; } else { StopClient(); m_ClientButton.GetComponentInChildren<Text>().text = "Start Client"; } }

//Start the Server when this Button is pressed public void ServerButton() { Debug.Log("Server : " + m_ServerStarted); if (m_ServerStarted == false) { StartServer(); m_ServerButton.GetComponentInChildren<Text>().text = "Stop Server"; } else { StopServer(); ServerReturnToLobby(); m_ServerButton.GetComponentInChildren<Text>().text = "Start Server"; } } }