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 Anatsol · Mar 18, 2013 at 03:42 PM · arraylistdatabaseinventoryrpg

How can I store game data outside of scripts.(e.g Total list of inventory items)

I've been poking around for the answer for this question, but I keep getting questions and answers that are close in wording, but not exactly what I'm looking for.

My current project is a game with RPG elements, and my current problem right now is items.

The player's current inventory seems like a pretty straight forward concept: Use a list/associative array to create a list of items actively in the player's inventory, with their associated values set to the number of items of that name. Pretty straight forward.

But what about the overall item list/table?

My item class will look something like this:

 psuedocode:
 Public Class Item
 {
 int ID //The item's relative ID in the game.
 string Name // Item's displayed name.
 boolean equip // Can item be equiped?
 boolean use // Can item be used?
 enum location //None, Body, Hands, Feet, Accessory
 int modAttribute //A few of these, for each of the game's attributes.
 //Other variables, such as item# limit, game icons, etc, including all 
 //of the "Gets/Sets" for these properties.
 
 }




Naturally, I could create a huge array(of this item class) to contain all of the game's inventory data in code, but it seems like it would be a pain to work with both in adding/removing/editing items, and with assigning items to certain enemies/chests/etc in order to be dropped/otherwise handled.

I've worked with databases before, but only non-local/web databases(MySql and the like.) They seem like they would be a good solution, if only they were local and/or light weight enough to use with a game. I've stored data as CSVs before, but it seems like a horrible idea to publish a game where the game's data is stored in plain/mostly plain text, and editing a CSV formated inventory list still feels.. sub-optimal.

Is there an easy way to store this kind of data outside of scripts, without a web database, and preferably in a format that couldn't easily be edited by a curious gamer in notepad?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by murkantilism · Mar 18, 2013 at 04:03 PM

If you really want to deter your players from editing the inventory data, you could use an XML database, they are relatively easy to use. Then you can simply encrypt the XML text.

Take a look at this page to learn about XML encryption in Unity.

Comment
Add comment · Show 2 · 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
avatar image Anatsol · Mar 18, 2013 at 04:16 PM 0
Share

Super. I can work with this. Seems like it would be easy to save relevant game-state variables in this format as well.

Thanks for the example.

Do you know how intensive this is for processing? It mentions it towards the bottom of the blog post, and I have a hard time gauging exactly what he means by moderate sized X$$anonymous$$L file.

I thinking around 100~ items, which could be anywhere from 500-1000 lines of X$$anonymous$$L.

avatar image murkantilism · Mar 18, 2013 at 04:22 PM 0
Share

No problem, I'm not sure how processor intensive that method is, you may want to search for less resource heavy methods.

I$$anonymous$$O, 1000 lines of X$$anonymous$$L qualifies as a "moderate" sized X$$anonymous$$L file.

avatar image
1

Answer by nsxdavid · Mar 18, 2013 at 03:58 PM

The basic answer for how to keep someone from editing your data files "easily" is to encrypt the file. Roll your own or use the built-in capabilities.

If you want a light-weight embeded database that is appropriate for a game, there are multiple assets for integrating SQLite databases to your game. For example.

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

12 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

Related Questions

Setting generic list length 2 Answers

Can't Assign Item In Array 1 Answer

Convert Inventory from JS to C# (problem with list) 2 Answers

A node in a childnode? 1 Answer

Problem with dropping items from my inventory 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