OnJoinedRoom не вызывается - PullRequest
1 голос
/ 07 июня 2019

Когда игрок входит в комнату, я хочу назначить ему определенную роль на основе HashTable.Однако кажется, что OnJoinedRoom даже не вызывается, так как Debug.Log не появляется.

Я проверил, что я использую MonoBehaviourPunCallbacks.Я использую Unity (2019.1.0f2 personal) и Photon 2

public class GameHandler : MonoBehaviourPunCallbacks
{
    public readonly string[] ROLES = {
        "Villager",
        "Werewolf",
        "Seer",
        "Werewolf",
        "Doctor",
        "Villager"
    };

    Hashtable PlayerProperties = new Hashtable
    {
        {"Role", null}, 
        {"Team", null}
    };

    public TMP_Text ROLE_TXT;

    private void Start()
    {
        PhotonNetwork.LocalPlayer.SetCustomProperties(PlayerProperties);
    }

    public override void OnJoinedRoom()
    {
        Debug.Log("OnJoinedRoomCalled");
        GetRoleAndTeam();
    }

    private void GetRoleAndTeam()
    {
        PlayerProperties["Role"] = ROLES[PhotonNetwork.CurrentRoom.PlayerCount - 1];

        PhotonNetwork.LocalPlayer.SetCustomProperties(PlayerProperties);        

        string MyRole = (string) PhotonNetwork.LocalPlayer.CustomProperties["Role"];

        Debug.Log("My Role :");

        ROLE_TXT.text = MyRole;

        if (MyRole.Equals("Werewolf"))
        {
            PlayerProperties["Team"] = "Werewolves";

            PhotonNetwork.LocalPlayer.SetCustomProperties(PlayerProperties); 
        }

        else
        {
            PlayerProperties["Team"] = "Villagers";

            PhotonNetwork.LocalPlayer.SetCustomProperties(PlayerProperties);
        }
    }
}

Я ожидаю, что он вызовет OnJoinedRoom, который поэтому запускает журнал отладки, а также GetRoleAndTeam (), но OnJoinedRoom не вызывается

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...