Photonnetwork does not contain a definition for 'playerName'

I am very new to coding and I am currently following this tutorial:

The errors I am having are:

This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;

public class MenuController : MonoBehaviour
{
[SerializeField] private string VersioName = “0.1”;
[SerializeField] private GameObject UsernameMenu;
[SerializeField] private GameObject ConnectPanel;

[SerializeField] private TMPro.TMP_InputField UsernameInput;
[SerializeField] private TMPro.TMP_InputField CreateGameInput;
[SerializeField] private TMPro.TMP_InputField JoinGameInput;

[SerializeField] private GameObject StartButton;
private void Awake()
{
PhotonNetwork.ConnectUsingSettings();
}

private void OnConnectedToMaster()
{
PhotonNetwork.JoinLobby(TypedLobby.Default);
Debug.Log(“Connected”);
}

public void ChangeUsernameInput()
{
if (UsernameInput.text.Length >= 3)
{
StartButton.SetActive(true);
}
else
{
StartButton.SetActive(false);
}
}

public void SetUserName()
{
UsernameMenu.SetActive(false);
PhotonNetwork.playerName = UsernameInput.text;
}

public void CreateGame()
{
PhotonNetwork.CreateRoom(CreateGameInput.text, new RoomOptions() { maxPlayers = 3 }, null);
}
}

This is not related to 2D so please don’t use this forum for anything other than 2D related posts.

I’ll move your post to the “Getting Started” sub-forum for you though.

You should probably refer to the documentation for the PhotonNetwork, maybe the tutorial is outdated?

Note, here’s how to post code on the forums: Using code tags properly

Thanks.

1 Like