What is the best way to store information of several items?

Hello everyone.

I have created a Billboard prefab in my game that has an image and a text description field.

What I need is for my code to sweep some specific areas of the hierarchy and according to the GameObject found, fill the Billboard image and description.

Now two things have to happen.

The first one is easy. The text field from the Billboard is simply the name of the GameObject.
The second one is where it gets tricky. According to its name, a predefined image need to be filled to the Billboard Image field.

Since I will be creating several Scenes and A LOT of images to choose from (certainly hundreds, probably thousands) I don’t know what is the correct way to store the information of the item in question.

Each item needs to have these fields:
[ID] Bool
[NAME] String
[CATEGORY] String
[UNIQUE] Bool

So, there are two possibilities here.
If an item IS NOT UNIQUE, then the code must fill the current Image with the category image.
if it IS UNIQUE, then it must use an image that was exclusively designed for that item.

I thought about using a Database OR Scriptable Objects. Both of them would access a folder inside the project with the images.

The downside of the Scriptable Objects I found is that I can’t think of a way to keep an item ID effectively.

I was wondering if you guys could tell me if I am going on the right direction or if there is a more recommended way to do this, because I haven’t found a better and clear way yet.

Just make a class that contains that data, and serialize your list of them to and from a file using JSON.

You could use a GUID over an auto-incrementing ID.
I have a setup like this for items in my game:

public class Item : ScriptableObject {
   [SerializeField] private string guid;

   public string GUID => guid;

#if UNITY_EDITOR

   private void Reset() => GenerateGUID();

   [ContextMenu("Generate GUID")]
   private void GenerateGUID() => guid = Guid.NewGuid().ToString();

#endif
}
1 Like

I got quite confused by the answers…

Could you elaborate please?

And in your answer, I could not understand how that works.

I am actually tending to using SQLite for this, given that there will be many items. I cant see how the suggestions you made would be the ideal case for handling that many options with ease.

I am struggling with finding a good tutorial on how to do the DB communication with unity. Can someone give me a direction?

Just look up how to do it in .NET or C#.

Hello. could you do it?

Please don’t necro posts like this.