7 erros no script conectar
2 participantes
Página 1 de 1
7 erros no script conectar
erros:
Assets/Script/Conectar.cs(27,31): error CS0305: Using the generic method `UnityEngine.GameObject.GetComponent<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(83,102): error CS0305: Using the generic method `UnityEngine.GameObject.GetComponent<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(99,18): error CS0305: Using the generic method `UnityEngine.Component.GetComponent<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(101,106): error CS0305: Using the generic method `UnityEngine.GameObject.GetComponent<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(105,32): error CS0305: Using the generic method `UnityEngine.Component.GetComponentInChildren<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(107,33): error CS0305: Using the generic method `UnityEngine.Component.GetComponentInChildren<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(139,78): error CS0305: Using the generic method `UnityEngine.Component.GetComponent<T>()' requires `1' type argument(s)
script:
Assets/Script/Conectar.cs(27,31): error CS0305: Using the generic method `UnityEngine.GameObject.GetComponent<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(83,102): error CS0305: Using the generic method `UnityEngine.GameObject.GetComponent<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(99,18): error CS0305: Using the generic method `UnityEngine.Component.GetComponent<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(101,106): error CS0305: Using the generic method `UnityEngine.GameObject.GetComponent<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(105,32): error CS0305: Using the generic method `UnityEngine.Component.GetComponentInChildren<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(107,33): error CS0305: Using the generic method `UnityEngine.Component.GetComponentInChildren<T>()' requires `1' type argument(s)
Assets/Script/Conectar.cs(139,78): error CS0305: Using the generic method `UnityEngine.Component.GetComponent<T>()' requires `1' type argument(s)
script:
- Código:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[RequireComponent(typeof(Collider))]
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 :
Re: 7 erros no script conectar
voce tem que dar o nome do componente,especificar o componente do objeto a ser chamado, que vc quer pegar do objeto; tip0 GameObjeto obj=getComponent<T>() onde "T" é o componente; ou GameObjeto obj=getComponent("nomedocomponente") ,GameObjeto obj=getComponent(typeof(Gameobjeto)), ex: GameObject.getcomponent<transform>(), ;
Re: 7 erros no script conectar
opa, colocar exemplo em codigo
- Código:
GameObject.getComponent<T>() //T e o componente a ser pego ,vc deve especificar o tipo de componente no argumento entre -> <T>
Re: 7 erros no script conectar
tipo na linha 27 onde ta com o erro eu deixo assimfelipehobs1 escreveu:opa, colocar exemplo em codigo
- Código:
GameObject.getComponent<T>() //T e o componente a ser pego ,vc deve especificar o tipo de componente no argumento entre -> <T>
[list=linenums]
[*] rt = containerDeSalas.GetComponent (T);
[/list]
PatifeCraft- Avançado
- PONTOS : 2868
REPUTAÇÃO : 6
Respeito as regras :
Re: 7 erros no script conectar
na linha 27 como vc ta querendo pegar um "RectTranform" deve ficar assim:
- Código:
rt = containerDeSalas.GetComponent ("RectTranform");
ou
rt = containerDeSalas.GetComponent <RectTranform>();
ou
rt = containerDeSalas.GetComponent (typeof(RectTranform));
//algum desses deve ser deprecado ou obselete sugiro usar a opcao 2,
Re: 7 erros no script conectar
blz voce tem skype se voce tiver me add \PatifeCraft/felipehobs1 escreveu:kkk nao esquece do "S" no RectTranform huehue
PatifeCraft- Avançado
- PONTOS : 2868
REPUTAÇÃO : 6
Respeito as regras :
Tópicos semelhantes
» Erros do Script
» Erros nesse script
» Erros Diversos no Script
» [RESOLVIDO] Erros do Script
» Erros nesse script?
» Erros nesse script
» Erros Diversos no Script
» [RESOLVIDO] Erros do Script
» Erros nesse script?
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos