The name 'PunPlayerTag' does not exist in the current context

Options
I am getting this error (The name 'PunPlayerTag' does not exist in the current context) for this code :
using System.Collections.Generic;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using Hashtable = ExitGames.Client.Photon.Hashtable;

public static class Assigner
{
    //needed for player properties
    public const string TagKey = "tag";
 
    public static void AssignTagToRandomPlayer(string tag)
    {
        var players = PhotonNetwork.PlayerList;
        var randomPlayer = players[Random.Range(0, players.Length)];
        SetTag(randomPlayer, tag);
    }
 
    public static Player GetPlayerWithTag(string tag)
    {
        var players = PhotonNetwork.PlayerList;
        foreach (var player in players)
        {
            if (string.Equals(GetTag(player), tag))
            {
                return player;
            }
        }
 
        return null;
    }
 
    public static List<Player> GetPlayersWithTag(string tag)
    {
        List<Player> playersWithTag = new List<Player>();
        var players = PhotonNetwork.PlayerList;
        foreach (var player in players)
        {
            if (string.Equals(GetTag(player), tag))
            {
                playersWithTag.Add(player);
            }
        }
 
        return playersWithTag;
    }
 
    private static void SetTag(Player player, string tag)
    {
        var customProp = new Hashtable() {{PunPlayerTag.TagKey, tag}};
        player.SetCustomProperties(customProp);
    }
 
    private static string GetTag(Player player)
    {
        if (player.CustomProperties.TryGetValue(PunPlayerTag.TagKey, out var value))
        {
            return (string) value;
        }
 
        return "";
    }
}

anyone jst what is wrong...?

HELP.. :(

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @psychosija,

    Thank you for choosing Photon!

    PunPlayerTag is not part of Photon codebase as far as I know.
    So this is either a custom class you made or a class from an external 3rd party asset or this simply a copy/paste leftover.
    If this class does exist in a file in your project then make sure you add its namespace to the list of usings or call it via its full name.
    You may also try to adjust assembly definition files to be able to access it from a different assembly maybe?