Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Abacab · Jun 03, 2015 at 07:51 PM · playerprefsiapitem

Consumable (IAP) items

Hello!

I'd like to create a consumable item that you can gain in the game and also purchase through the in-game store. I think PlayerPrefs wouldn't work since the users lose all their consumables if they delete the app.

How have you implemented purchasable consumables to your games? I tried looking for tutorials on Youtube but couldn't find any.

The way I'd do it with PlayerPrefs:

 public void ConsumableButton() 
 {
   if (PlayerPrefs.GetInt ("ConsumableAmount") >= 1)
   {
     ConsumableEffect();
     ConsumableAmount--; //what is the opposite of '++'?
     PlayerPrefs.SetInt ("ConsumableAmount", ConsumableAmount);
     // Only usable once per level
     consumableButton.GetComponent<CanvasGroup>.interactable = false;
   }
 }

Thanks in advance!

Comment
Add comment · Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image instruct9r · Jun 03, 2015 at 09:54 PM 0
Share

I think if you want to put something in the game, that shoud not be deleted, when the game is deleted, then you shoud store that information somewhere on a server and assign it to the player userName (GameCenter username or in game userName)... Other Option is to make it with iAP (If it's android or iOS), then the player can restore purchase...

avatar image Abacab · Jun 03, 2015 at 09:56 PM 0
Share

Does Apple provide a way to store the information on their servers?

The other option seems to not work in this case, since consumables shouldn't be restore-able(?)

avatar image instruct9r · Jun 04, 2015 at 09:15 AM 0
Share

with iOS you can make several type of iAP's. Consumables and Non Consumables. The non Consumables can be restored, the consumables cannot be restored.... I think you can use iCloud to store some information but not realy sure, maybe you can check in the documentations.. Or somebody more experienced coud answer..

avatar image Abacab · Jun 04, 2015 at 01:25 PM 0
Share

If the player deletes the game and has previously purchased consumables that are still unused, should they be stored in case the user returns or is it the user's own fault that the consumables disappear when he deletes the app?

avatar image HarshadK · Jun 04, 2015 at 01:37 PM 1
Share

No. PlayerPrefs is the worst way to store consumables. They are the least secure. You might want to use encrypted PlayerPrefs or binary files at least to make it secure.

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Saving a list of items 1 Answer

How to save an item as bought in player prefs? 0 Answers

PlayerPrefs on gameObject 1 Answer

Saving and Re-calling Remove Ads Functionality *Newbie!* 0 Answers

How to handle IAP refund in iOS? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges