r/UnityHelp • u/Qulddell • Aug 17 '21
PROGRAMMING Unity Problems with Photon
When i try to "play" the game an error message with yellow pops up saying:
"PUN is in development mode (development build). As the 'dev region' is not empty (eu) it overrides the found best region. See PhotonServerSettings.
UnityEngine.Debug:LogWarning (object)"
I know from tutorials that i should get a message saying: "Received your UserID from server. Updating local value to: [Number]"
But i don't get that message...
So beside this error i am unsure if it is best to use Photon Pun or another service, for a multiplayer 12 player game :)
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;
public class NetworkScript : MonoBehaviourPunCallbacks
{
public static NetworkScript lobby;
public Button joinPlay;
public Button cancelSearch;
// Start is called before the first frame update
private void Avake()
{
lobby = this;
}
void Start()
{
PhotonNetwork.Disconnect();
PhotonNetwork.ConnectUsingSettings();
}
void OnEnable()
{
//Register Button Events
joinPlay.onClick.AddListener(() => PlayGame());
cancelSearch.onClick.AddListener(() => CancelGame());
}
public void PlayGame()
{
PhotonNetwork.JoinRandomRoom();
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
Debug.Log("Tried to join and failed");
CreateRoom();
}
void CreateRoom()
{
int randomRoomName = Random.Range(0, 10000);
RoomOptions roomOps = new RoomOptions() { IsVisible = true, IsOpen = true, MaxPlayers = 12 };
PhotonNetwork.CreateRoom("Room" + randomRoomName, roomOps);
Debug.Log("Room Created :) ");
}
public override void OnJoinedRoom()
{
Debug.Log("Room had been joined");
}
public override void OnCreateRoomFailed(short returnCode, string message)
{
Debug.Log("Tried to make a room, makes a new one.");
CreateRoom();
}
public override void OnConnectedToMaster()
{
Debug.Log("Player has connected to the Photon master server");
}
void CancelGame()
{
PhotonNetwork.LeaveRoom();
}
public void OnFailedToConnectToPhoton()
{
Debug.Log("doens't connect to server...");
}
}
1
u/Qulddell Aug 19 '21
So i did found a place where i did need to put in a "0", but it still don't connect to the server or is very slow.
Here is what happen just as i open the scene with he scripts in. No log of connection verification.
https://imgur.com/eNH8J23
And when i press a Join button to join a room.
https://imgur.com/DfOA0u8