error CS0619: 'HostData' is obsolete: 'The legacy networking system has bee
2 participantes
Página 1 de 1
error CS0619: 'HostData' is obsolete: 'The legacy networking system has bee
- Código:
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class NetworkJogo : MonoBehaviour
{
public GameObject[] Player;
public Transform SpawnPoint;
private string ServerName = "Nome do Servidor";
private string ServerPass = "Senha do Servidor";
public static string MyName="Seu Nome";
public GameObject ChatObject;
private HostData tempData;
public static GameObject PlayerCasa;
void Update()
{
MasterServer.RequestHostList ("YoutubeTutorial");
}
void OnGUI()
{
if (!Network.isServer && !Network.isClient) {
ServerName = GUI.TextField (new Rect (20, 20, 150, 25), ServerName);
ServerPass = GUI.TextField (new Rect (20, 50, 150, 25), ServerPass);
MyName = GUI.TextField (new Rect (Screen.width / 2 - 100, 10, 200, 25), MyName);
if (GUI.Button (new Rect (20, 80, 150, 25), "Criar Sala")) {
Network.InitializeServer (32, (int)Random.Range (10000, 99999), !Network.HavePublicAddress ());
MasterServer.RegisterHost ("YoutubeTutorial", ServerName, ServerPass);
}
HostData[] data = MasterServer.PollHostList ();
if (data != null) {
GUI.Box (new Rect (Screen.width - 180, 20, 160, Screen.height - 10), "Salas");
for (int i = 0; i< data.Length; i++)
{
if (GUI.Button (new Rect (Screen.width - 170, 50, 140, 25), data [i].gameName + " " + data [i].connectedPlayers.ToString () + "/" + (data [i].playerLimit - 1).ToString ()))
{
tempData= data [i];
}
}
}
if (tempData!=null)
{
GUI.Box(new Rect(Screen.width / 2-80, Screen.height / 2-40,160,80),"Senha");
ServerPass=GUI.TextField(new Rect(Screen.width / 2-75,Screen.height /2 -20,150,25),ServerPass);
if (GUI.Button (new Rect(Screen.width / 2-75, Screen.height /2+5,70,25),"Entrar"))
{
if (ServerPass==tempData.comment)
Network.Connect(tempData);
}
if (GUI.Button(new Rect(Screen.width /2 +5, Screen.height /2+5, 70,25),"Cancelar"))
tempData=null;
}
}
}
void OnServerInitialized()
{
Network.Instantiate (Player[PlayerPrefs.GetInt("PlayerNumber")], SpawnPoint.position, Quaternion.identity, 0);
GetComponent<Camera> ().enabled = false;
PlayerPrefs.SetString ("MyName", MyName);
GameObject.Destroy (PlayerPreview.LastCharacter);
PlayerPreview.isActived = false;
ChatObject.SetActive (true);
}
void OnConnectedToServer()
{
Network.Instantiate (Player[PlayerPrefs.GetInt("PlayerNumber")], SpawnPoint.position, Quaternion.identity, 0);
GetComponent<Camera> ().enabled = false;
GameObject.Destroy (PlayerPreview.LastCharacter);
PlayerPreview.isActived = false;
ChatObject.SetActive (true);
}
void OnDisconnectedFromServer () {
GetComponent<Camera> ().enabled = true;
// PlayerPrefs.SetInt("PlayerNumber", 0);
PlayerPreview.isActived = true;
ChatObject.SetActive (false);
}
}
Fazia um bom tempo que não mexia no Unity e Agora importei meu projeto e me deparei com esse erro, como resolvo?
Kelvyn_Feitosa- Avançado
- PONTOS : 3517
REPUTAÇÃO : 3
Respeito as regras :
Re: error CS0619: 'HostData' is obsolete: 'The legacy networking system has bee
infelizmente o sistema Unet foi removido das versões mais recentes da Unity...Kelvyn_Feitosa escreveu:
- Código:
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class NetworkJogo : MonoBehaviour
{
public GameObject[] Player;
public Transform SpawnPoint;
private string ServerName = "Nome do Servidor";
private string ServerPass = "Senha do Servidor";
public static string MyName="Seu Nome";
public GameObject ChatObject;
private HostData tempData;
public static GameObject PlayerCasa;
void Update()
{
MasterServer.RequestHostList ("YoutubeTutorial");
}
void OnGUI()
{
if (!Network.isServer && !Network.isClient) {
ServerName = GUI.TextField (new Rect (20, 20, 150, 25), ServerName);
ServerPass = GUI.TextField (new Rect (20, 50, 150, 25), ServerPass);
MyName = GUI.TextField (new Rect (Screen.width / 2 - 100, 10, 200, 25), MyName);
if (GUI.Button (new Rect (20, 80, 150, 25), "Criar Sala")) {
Network.InitializeServer (32, (int)Random.Range (10000, 99999), !Network.HavePublicAddress ());
MasterServer.RegisterHost ("YoutubeTutorial", ServerName, ServerPass);
}
HostData[] data = MasterServer.PollHostList ();
if (data != null) {
GUI.Box (new Rect (Screen.width - 180, 20, 160, Screen.height - 10), "Salas");
for (int i = 0; i< data.Length; i++)
{
if (GUI.Button (new Rect (Screen.width - 170, 50, 140, 25), data [i].gameName + " " + data [i].connectedPlayers.ToString () + "/" + (data [i].playerLimit - 1).ToString ()))
{
tempData= data [i];
}
}
}
if (tempData!=null)
{
GUI.Box(new Rect(Screen.width / 2-80, Screen.height / 2-40,160,80),"Senha");
ServerPass=GUI.TextField(new Rect(Screen.width / 2-75,Screen.height /2 -20,150,25),ServerPass);
if (GUI.Button (new Rect(Screen.width / 2-75, Screen.height /2+5,70,25),"Entrar"))
{
if (ServerPass==tempData.comment)
Network.Connect(tempData);
}
if (GUI.Button(new Rect(Screen.width /2 +5, Screen.height /2+5, 70,25),"Cancelar"))
tempData=null;
}
}
}
void OnServerInitialized()
{
Network.Instantiate (Player[PlayerPrefs.GetInt("PlayerNumber")], SpawnPoint.position, Quaternion.identity, 0);
GetComponent<Camera> ().enabled = false;
PlayerPrefs.SetString ("MyName", MyName);
GameObject.Destroy (PlayerPreview.LastCharacter);
PlayerPreview.isActived = false;
ChatObject.SetActive (true);
}
void OnConnectedToServer()
{
Network.Instantiate (Player[PlayerPrefs.GetInt("PlayerNumber")], SpawnPoint.position, Quaternion.identity, 0);
GetComponent<Camera> ().enabled = false;
GameObject.Destroy (PlayerPreview.LastCharacter);
PlayerPreview.isActived = false;
ChatObject.SetActive (true);
}
void OnDisconnectedFromServer () {
GetComponent<Camera> ().enabled = true;
// PlayerPrefs.SetInt("PlayerNumber", 0);
PlayerPreview.isActived = true;
ChatObject.SetActive (false);
}
}
Fazia um bom tempo que não mexia no Unity e Agora importei meu projeto e me deparei com esse erro, como resolvo?
https://support.unity.com/hc/en-us/articles/360001252086-UNet-Deprecation-FAQ
você poderia migrar para Photon ou DarkRift, que são ótimos sistemas de rede.
Tópicos semelhantes
» Ajuda ae error CS1525: Unexpected symbol `if' como ajeito esse error no script da lanterna?
» [Dúvida]Erro "UnityEngine.AI.NavMeshAgent.Stop()' is obsolete" como resolver ?
» using UnityEngine.networking
» [RESOLVIDO] Animação Em Legacy
» Animação bugada com Legacy
» [Dúvida]Erro "UnityEngine.AI.NavMeshAgent.Stop()' is obsolete" como resolver ?
» using UnityEngine.networking
» [RESOLVIDO] Animação Em Legacy
» Animação bugada com Legacy
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos