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 panendraommina · May 15, 2021 at 07:52 AM · jsonsave datasave file

the Json script elements are saved even I build a new apk ?

let me explain the question i had developed a game using unity 3D in which json is used as data base to store data . i had bought some items in editor and some items are unlocked . when I build an apk . the items which are unlocked still remains same on my phone .

[image on my editor]: /storage/temp/180717-screenshot-362.png

[image on my phone ]: /storage/temp/180718-screenshot-20210515-130836977-1.jpg

why it is happening like that . the save states are same on both images , please help

screenshot-362.png (50.0 kB)
screenshot-20210515-130836977-1.jpg (211.7 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · May 15, 2021 at 09:17 AM

Well, where did you store your "json database"? It's just a file that is completely outside of Unity's control. If you edit the file in the editor, it will be shipped with your game in it's current shape and form. So if you directly modify the file, those changes will of course persist. Keep in mind that while in the editor you can directly change files in the assets folder. However that is not possible in a build game since the assets are compiled during build.


So it would be interesting to know how you intend to use your json database in the build? Where do you actually store the modified file on the device? For standalone builds one could use the streaming assets folder to store such files, however that's not possible for Android or WebGL as all assets that are shipped with your game are inside the APK file. There's no direct path to those assets. You usually use the persistentDataPath to store modified information on the target device. It's common to ship pre populated databases as either TextAsset or inside StreamingAssets and extract that file at the first launch into the persistentDataPath where you will be modifying the file. Note that this method has some drawbacks: when you update your game and ship it with a new / updated database (maybe you added new items?) they would not appear on the target device since once we created the file in the peristentDataPath, we would continue to use that one.


One solution is to seperate out the actual database data you specify for your game and the data that is changed on the user's device into seperate files. That way you can keep your database inside your project (load it from a TextAsset or from your server or whatever) so your database is always up-to-date. When the user buys something you just record this in a seperate file in the persistentDataPath where you just "link" to your actual database entries. We don't know how you organised your items in your database, but usually each item should have a unique id or name. So in the persistent datapath you would just need to store the bought-state for each item (plus whatever else information you need, like the date / time it was bought).


So when loading the database you would always load your internal database that is never changed on a user's device (only you could update it) and you would augment it with the data you stored in the json file on the user's device.

Comment
Add comment · Share
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

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

120 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Save Game format that is change proof and secure 0 Answers

Unity problem when i convert playerprefs save to the standard file io save 0 Answers

Need help on Json Script 1 Answer

PlayerPrefs not saving in build 1 Answer

How do I save a List in my project? 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