[P2] Inventory System - Preparation - Scriptable Objects



1. What is Scriptable Object?

"A ScriptableObject is a data container that you can use to save large amounts of data, independent of class instances. One of the main use cases for ScriptableObjects is to reduce your Project’s memory usage by avoiding copies of values" - Unity - Manual: Scriptable Objects 

For example, if you have the "ItemInfo" script with 3 float variables (Attack, HP, MP), then you attach them into 5 objects, it will cost you 3 x 5 = 15 spaces. However, by using ScriptableObject you can create 5 different data as assets which costs 5 spaces that reference from the data container. Another common uses of Scriptable Object are for Save-Load, Player Stats,...

2. Create Scriptable Object for Items

The way I do is just a simple way to add item's information:


Then, it will create the Item Info "new Item" in the Assets Folder:


After that, you can create your own Item Stats as many assets as you have. However, I believe that there's other optimal ways to handle these information (I will update this post when I can do these ways)


3. How to add image below the item info



That is the end of the Part 2: Inventory System - Preparation - Scriptable Objects. If you have any questions, comment in the box below 


Comments

Post a Comment