Proper way to use SetPlayerData



  • Hi,
    I am not sure if I am using the SetPlayerData correctly. I have a "Term of Use/Instructions" that needs to be shown only once (the first time the game is loaded) but I do not want it to show up at the same time as the main menu so the two panels should be mutually exclusive. My code works fine when I run it from Unity. However once it is built and started from Steam, the "Term of Use panel/Instructions" and "Main Menu/Pause Menu" show up at the same time. This is my last bug to fix!! Code is:

       void Start()
        {
            if (DBManager.GetPlayerData("termofuse").AsInt == 0)
            {
                Debug.Log("Term of use is 0 meaning it was never shown");
                panelInformationAndInstructions.SetActive(true);  //Show term of use
                panelPauseMenuUI.SetActive(false);  //Do not show the main menu/pause menu
                DBManager.SetPlayerData("termofuse", new SIS.SimpleJSON.JSONData(1));  //set the "termofuse" to 1 which mean it was shown
                PlayfabManager.SetPlayerData();
            }
            else
            {
                Debug.Log("Term of use is 1 meaning do not show instructions");
                panelInformationAndInstructions.SetActive(false);   //Do not show the term of use
            }
        }
    

    I really cannot figure this one out, I tried different things but no luck...



  • Hi,

    your calls to GetPlayerData and SetPlayerData look good. The issue must be with the values you receive when running the Steam build. Did you debug the GetPlayerData values or look into PlayFab to see what is stored for that user?

    On a different note, the issue with seeing both panels could be that they are both active on launch before your code is executed? I wouldn't do it that way. Actually, you would not need an 'else' statement at all. Have the "pause menu" active and the "terms of use" panel disabled but layered on top. If GetPlayerData is 0, activate the "terms of use" panel (displayed on top). Otherwise do nothing.



  • I did look for for the values on playfab, everything looks good.
    Also the Term of Use/Instruction panel is disabled. Really strange. Anyways thx for the feedback, Ill keep trying different things...


Log in to reply