- Home /
Can I save class instances in a prefab-like way?
Hi all,
I've been looking into this myself, but either the issue hasn't come up before or my vocabulary is incorrect. Essentially, what I'd like to do is save pre-created instances of classes that I can assign to various components within the inspector.
For context, I'm creating an inventory system and am using a class Item to describe any items that can be stored in inventory. An object of this class would be ex. Health Potion, stackable=True, value=100. My initial approach was to create an array of inventory items at the start of the game, and then reference them by array index when working in the editor. Things would be much smoother if I can simply reference existing Item objects.
Is what I'm hoping to achieve possible? Is there an easier way I could be going about this? Any input is appreciated!
Answer by Trevdevs · Jun 29, 2018 at 03:17 AM
Ah you sure are a genius you want ScriptableObjects
These are the best thing about unity in my opinion i use them probably way more than I should
heres some documentation about them cheers :)
https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/scriptable-objects
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Procedural rail generation from prefabs 0 Answers
Constructor giving nullreference error 1 Answer
How to generate different diagonal platforms? 0 Answers
Distribute terrain in zones 3 Answers