PhotonNetwork is not working

Hey, I am a Developer and I am using Unity!! Today I decided to make a multiplayer game...But when I tried to write my code it didn't work and Unity could not find PhotonNetwork.NickName Here is my code

using Photon.Pun;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace Rpg.Menus
{
public class MainMenuInput : MonoBehaviour
{
[SerializeField] private TMP_InputField nameInputField = null;
[SerializeField] private Button continueButton = null;

private const string PlayerPrefsNameKey = "PlayerName";

private void Start() => SetUpInputField();

private void SetUpInputField()
{
if (!PlayerPrefs.HasKey(PlayerPrefsNameKey)) { return; }

string defaultName = PlayerPrefs.GetString(PlayerPrefsNameKey);

nameInputField.text = defaultName;

setPlayerName(defaultName);
}

private void setPlayerName(string name)
{
continueButton.interactable = !string.IsNullOrEmpty(name);
}

public void SavePlayerName()
{
string playerName = nameInputField.text;

PhotonNetwork.NickName = playerName;

PlayerPrefs.SetString(PlayerPrefsNameKey, playerName);
}
}
}


also, I use Photon Pun 2 Free Version

Comments

Sign In or Register to comment.