Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

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