OnJoinedRoom not being called
Options
I am using photon to make a FPS game for android. Here is the code:
This is the code from button. It is instantiated and it should join the room, then load the scene. In other scripts, "onjoinedroom" callback works, even if I inherite from Photon.MonoBehaveiour, not from PUNBehaveiour. What is wrong?
using UnityEngine; using UnityEngine.UI; public class SceneLoaderButton : Photon.PunBehaviour { public string roomName, mapNameGL, password; public GameObject loadingPan; public MenuRooms menuManager; // Use this for initialization void Start () { Button btn = GetComponent<Button> (); btn.onClick.AddListener (ConnectCustomRoom); } // Update is called once per frame void Update () { } void ConnectCustomRoom(){ string room = roomName; RoomInfo[] ri; ri = PhotonNetwork.GetRoomList (); bool correct = false; string passwd, mapName = ""; passwd = password; foreach (RoomInfo info in ri) { if (info.name == room) { if (info.customProperties ["Password"].ToString() == passwd) { print(info.playerCount + "/" + info.maxPlayers); if (info.playerCount < info.maxPlayers) { correct = true; } else { menuManager.error("No room for you"); } mapName = info.customProperties ["MapName"].ToString (); } else { menuManager.error("Incorrect password"); } } } mapNameGL = mapName; print(mapNameGL); if (correct) { print("Correct"); loadingPan.active = !loadingPan.active; PhotonNetwork.playerName = "Player" + UnityEngine.Random.Range (1000,9999).ToString(); PhotonNetwork.JoinRoom(room); } } void OnJoinedRoom() { print("Joined room: " + roomName); //We joined room, load respective map Application.LoadLevel(mapNameGL); } }
This is the code from button. It is instantiated and it should join the room, then load the scene. In other scripts, "onjoinedroom" callback works, even if I inherite from Photon.MonoBehaveiour, not from PUNBehaveiour. What is wrong?
0
Comments
-
Hi @edimemune,
Thank you for choosing Photon!
If you extendPunBehaviour
try this:public override void OnJoinedRoom() { print("Joined room: " + roomName); //We joined room, load respective map Application.LoadLevel(mapNameGL); }
1