Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

JS PlayerPrefs

Discussion in 'Scripting' started by foxkids94, Feb 11, 2016.

  1. foxkids94

    foxkids94

    Joined:
    Feb 11, 2016
    Posts:
    1
    How to save the costumes of the characters with PlayerPrefs, the action occurs in which the button "Buy" changed to "Equip", When you enter the game, the values are not saved.
    How to implement conservation.



    public function setShopCostumeScriptEnabled(state:boolean)
    {
    if (state == true)
    {
    this.enabled = true;//enable the script

    //enable or disable buy/ equip button
    if (costumeOwned == false)//if costume is not owned
    {
    tBuyButton.gameObject.SetActive(true);
    tEquipButton.gameObject.SetActive(false);
    }
    else if (costumeOwned == true)//if costume is owned
    {
    tBuyButton.gameObject.SetActive(false);
    tEquipButton.gameObject.SetActive(true);

    }
    }
    else
    this.enabled = false;

    }
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148