Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question unity does not always save data to playfab

Discussion in 'Multiplayer' started by brano42, Jun 12, 2023.

  1. brano42

    brano42

    Joined:
    Aug 25, 2020
    Posts:
    78
    Hello, I have a problem with saving data to playfab...
    my problem is that the data is saved, but only the first time when I log into the room again, the data is not saved. it is about saving the Player level when the player is the first in the table

    here is script please can someone help me please?

    Code (CSharp):
    1.  private void Update()
    2.     {
    3.      
    4.  
    5.      
    6.             if (TimerScene.timer <= 0 && container.transform.GetChild(0).GetComponent<ScoreBoardItem>().usernameText.text == MyPlayerName && SendScore == true)
    7.             {
    8.                 StartCoroutine(SaveData());
    9.  
    10.             }
    11.         }
    12.  
    13.  
    14.     IEnumerator SaveData()
    15.     {
    16.      
    17.         SendScore = false;
    18.         yield return new WaitForSeconds(1);
    19.         UserProfile.Instance.profileData.level += container.transform.GetChild(0).GetComponent<ScoreBoardItem>().Score;
    20.         UserProfile.Instance.SetUserData();
    21.         Debug.Log(PhotonNetwork.NickName + "." + "Score" + "-" + container.transform.GetChild(0).GetComponent<ScoreBoardItem>().Score);
    22.  
    23.  
    24.     }
     
    Last edited: Jun 13, 2023