Erro em script para photon
Página 1 de 1
Erro em script para photon
ola preciso de ajuda com um script ele esta com varios erros.
- Código:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Conectar : Photon.MonoBehaviour {
public Text textoDeConectado;
public Text textoDoBotao;
public GameObject containerDeSalas;
public GameObject prefabSalas;
public Button deConectar;
public Button deCriarSala;
public Scrollbar scrollDasSalas;
public GameObject painelDeSalas;
public GameObject canvas;
public Transform spawn;
public Text textoDoInput;
public GameObject mensagemDeProcurandoSalas;
private RectTransform rt;
// Use this for initialization
void Start () {
deCriarSala.gameObject.SetActive (false);
rt = containerDeSalas.GetComponent ();
painelDeSalas.SetActive(false);
}
// Update is called once per frame
void Update () {
if (PhotonNetwork.connected)
{
textoDeConectado.text = "Conectado";
textoDoBotao.text = "Desconectar";
listarSalas ();
}else
{
textoDeConectado.text = "Desconectado";
textoDoBotao.text = "Conectar";
}
}
int numAtualDeSalas = 0;
int numAnteriorDeSalas = 0;
void DisconnectedToPhoton ()
{
canvas.SetActive (true);
deCriarSala.gameObject.SetActive (false);
mensagemDeProcurandoSalas.SetActive (true);
painelDeSalas.SetActive (false);
}
void listarSalas ()
{
numAtualDeSalas = PhotonNetwork.GetRoomList ().Length;
if (numAtualDeSalas != numAnteriorDeSalas)
{
for (int i = 0; i < rt.childCount; i++)
{
Destroy (rt.GetChild (0).gameObject);
}
if (numAtualDeSalas == 0) {
mensagemDeProcurandoSalas.SetActive (true);
} else {
mensagemDeProcurandoSalas.SetActive (false);
}
insereSala (numAtualDeSalas);
}
numAnteriorDeSalas = numAtualDeSalas;
}
void adapteContainer (int numSalas)
{
RectTransform T = ((GameObject)Instantiate (prefabSalas, Vector3.zero, Quaternion.identity)).GetComponent ();
T.parent = rt;
T.localScale = new Vector3 (1, 1, 1);
T.offsetMax = Vector2.zero;
T.offsetMin = Vector2.zero;
rt.sizeDelta = new Vector2 (0, numSalas * 1.1f * T.rect.height);
Destroy (T.gameObject);
}
void insereSala (int numSalas)
{
adapteContainer (numSalas);
RoomInfo[] sala = PhotonNetwork.GetRoomList();
Text t = GetComponent ();
for (int i = 0; i < numSalas; i++) {
RectTransform T = ((GameObject)Instantiate (prefabSalas, Vector3.zero, Quaternion.identity)).GetComponent ();
T.parent = rt;
if (sala.Length > i)
t = T.GetChild (0).GetComponentInChildren ();
t.text = sala[i].name;
t = T.GetChild (1).GetComponentInChildren ();
t.text = sala[i].playerCount+" / "+sala[i].maxPlayers;
}
scrollDasSalas.value = 1;
}
void OnConnectedToPhoton ()
{
containerDeSalas.SetActive (true);
deCriarSala.gameObject.SetActive (true);
deConectar.interactable = true;
painelDeSalas.SetActive (true);
}
public void botaoConectar ()
{
if (!PhotonNetwork.connected)
{
deConectar.interactable = false;
PhotonNetwork.ConnectUsingSettings ("v1.0");
} else {
PhotonNetwork.Disconnect ();
}
}
public void criarSala ()
{
RoomOptions opcoesDaSala = new RoomOptions ()
{IsVisible = true, MaxPlayers = 10, IsOpen = true };
string nomeSala = textoDoInput.transform.parent.Find ("Placeholder").GetComponent ().text;
nomeSala = (textoDoInput.text==string.Empty) ? nomeSala : textoDoInput.text;
TypedLobby tL = new TypedLobby ();
PhotonNetwork.JoinOrCreateRoom (nomeSala, opcoesDaSala, tL);
}
void OnJoinedRoom ()
{
canvas.SetActive (false);
GameObject G = PhotonNetwork.Instantiate ("First Person Controller",spawn.position, Quaternion.identity,0);
}
void OnPhotonCreateRoomFailed ()
{
Debug.Log ("A criacao da sala falhou");
}
}
PatifeCraft- Avançado
- PONTOS : 2868
REPUTAÇÃO : 6
Respeito as regras :
PatifeCraft- Avançado
- PONTOS : 2868
REPUTAÇÃO : 6
Respeito as regras :
Tópicos semelhantes
» Erro de script de lobby photon.
» Script de tiro para o photon 2
» Erro Script Photon
» Erro Script Photon
» Erro em script do Photon Voice
» Script de tiro para o photon 2
» Erro Script Photon
» Erro Script Photon
» Erro em script do Photon Voice
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos